Commit 34ac7ab3b70d502bf9a2a14e8d4eec55f0014439
1 parent
76e155dd
Exists in
master
dir move
Showing
40 changed files
with
1457 additions
and
1457 deletions
Show diff stats
resources/application-local.properties
... | ... | @@ -1,139 +0,0 @@ |
1 | - | |
2 | -server.port=80 | |
3 | -server.session.timeout=10 | |
4 | - | |
5 | -spring.servlet.multipart.max-file-size=10MB | |
6 | -spring.servlet.multipart.max-request-size=20MB | |
7 | - | |
8 | -spring.jackson.time-zone=GMT+8 | |
9 | -spring.jackson.date-format=yyyy-MM-dd HH:mm:ss | |
10 | -spring.mvc.dateFormat = yyyy-MM-dd HH:mm:ss | |
11 | -spring.gson.serialize-nulls=true | |
12 | - | |
13 | -tokenfilter.enable=false | |
14 | - | |
15 | -logging.config=classpath:logback-local.xml | |
16 | - | |
17 | - | |
18 | -mail.host=smtp.taover.com | |
19 | -mail.port=25 | |
20 | -mail.username=taover-robot@taover.com | |
21 | -mail.password=Lexi@1798 | |
22 | -mail.smtp.auth=true | |
23 | -mail.smtp.sendFrom=taover-robot@taover.com | |
24 | - | |
25 | -spring.mvc.dispatch-options-request=true | |
26 | - | |
27 | -#spring.datasource.url=jdbc\:mysql\://192.168.3.189\:3306/8zyun_wxorder?useUnicode\=true&characterEncoding\=UTF-8&autoReconnect\=true&zeroDateTimeBehavior\=convertToNull&transformedBitIsBoolean\=true | |
28 | -#spring.datasource.username=root | |
29 | -#spring.datasource.password=root | |
30 | - | |
31 | - | |
32 | -spring.datasource.url=jdbc\:mysql\://121.42.142.102\:3306/bzyun_wxorder?useUnicode\=true&characterEncoding\=UTF-8&autoReconnect\=true&zeroDateTimeBehavior\=convertToNull&transformedBitIsBoolean\=true | |
33 | -spring.datasource.username=dev | |
34 | -spring.datasource.password=taover02 | |
35 | -spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |
36 | -spring.datasource.max-idle=10 | |
37 | -spring.datasource.max-wait=10000 | |
38 | -spring.datasource.min-idle=5 | |
39 | -spring.datasource.initial-size=5 | |
40 | - | |
41 | -#zto analysis address url | |
42 | -#zto.analysisAddress.url=https://localhost/Word_AnalysisAddress | |
43 | -zto.analysisAddress.url=https://hdgateway.zto.com/Word_AnalysisAddress | |
44 | -#taover analysis address url | |
45 | -taover.analysisAddress.url=http://address.taover.com/ | |
46 | -#kuaibao | |
47 | -kuaibao.analysisAddress.url=https://kop.kuaidihelp.com/api | |
48 | -kuaibao.analysisAddress.appId=105128 | |
49 | -kuaibao.analysisAddress.appKey=3310236ba4d6296e6e2346a7d9c824662510ff87 | |
50 | -kuaibao.analysisAddress.method=cloud.address.resolve | |
51 | -kuaibao.analysisAddress.methodSimple=cloud.address.cleanse | |
52 | - | |
53 | -#aliyun oss | |
54 | -accessKeyId=H4fIVB56iHjR6zQw | |
55 | -accessKeySecret=7bA395UltFp16kWPJT7Pfz0XYXCk4Q | |
56 | -endpoint=oss-cn-beijing.aliyuncs.com | |
57 | -bucket_contact=8zyun-oss | |
58 | -aliyun.mnsEndpoint=http://1225610490807748.mns.cn-hangzhou.aliyuncs.com | |
59 | -#https://8zyun-oss.oss-cn-beijing.aliyuncs.com | |
60 | -#mobile message url | |
61 | -wwltData=sname=dlmzty00&spwd=A6cU4Tyx&scorpid=&sprdid=1012888 | |
62 | -wwltUrl=https://seccf.51welink.com/submitdata/service.asmx/g_Submit | |
63 | - | |
64 | -#root ssy callcenter api config | |
65 | -ssy.callcenter.appid=c2MkSTjT8ghM | |
66 | -ssy.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0f | |
67 | - | |
68 | -pc.callcenter.appid=c2MkSTjT8ghZ | |
69 | -pc.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0G | |
70 | - | |
71 | -ssy.callcenter.subscribePreffixUrl=http://localhost/api/ | |
72 | -ssy.callcenter.subscribeSuffixUrl=/wxagentssymessagesubscribe | |
73 | - | |
74 | - | |
75 | -ssy.callcenter.url.openapiSurrogacyAgent=/api/v2/openapi/surrogacy/agent | |
76 | -ssy.callcenter.url.openapiSurrogacyQuerycontacts=/api/v2/openapi/surrogacy/querycontacts | |
77 | -ssy.callcenter.url.openapiSurrogacySendmessage=/api/v2/openapi/surrogacy/sendmessage | |
78 | -ssy.callcenter.url.openapiSurrogacyRegisteropenapi=/api/v2/openapi/surrogacy/registeropenapi | |
79 | -ssy.callcenter.url.openapiSurrogacyUnregisteropenapi=/api/v2/openapi/surrogacy/unregisteropenapi | |
80 | -ssy.callcenter.url.openapiCallcenterapibridgeService=/api/v2/openapi/callcenterapibridge/service | |
81 | -ssy.callcenter.url.openapiCallGroupMember=/api/v2/openapi/surrogacy/querygroupmember | |
82 | - | |
83 | - | |
84 | - | |
85 | - | |
86 | -ssy.upload.url=https://ssep.umsapi.com/api/v1/upload | |
87 | - | |
88 | -ssy.callcenter.sendMessage.preffixUrl=https://ssep.umsapi.com | |
89 | - | |
90 | -#weixin group text order confirm url | |
91 | -wxorder.url.grouptextorder.confirm=http://localhost:8100/confirm/ | |
92 | -wxorder.url.express.search=http://localhost:8100/confirm/query-logistics/ | |
93 | - | |
94 | -#ssy file server domain | |
95 | -ssy.fileserver.urlpreffix=https://ss0.umsapi.com | |
96 | - | |
97 | -wxorder.front.url.host=http://localhost:8100 | |
98 | - | |
99 | -platform.shop.registerUrl=http://localhost/common/authorization/index | |
100 | - | |
101 | -wxorder.platformgoods.matchurl=http://localhost/goods/channelgoods | |
102 | -wxorder.platformgoods.errororderurl=https://localhost/ordererror/index | |
103 | -wxorder.url.excellist=http://localhost/groupexcel/index | |
104 | - | |
105 | -#pc api | |
106 | -pc.callcenter.url.openapiSurrogacyRegisteropenapi=http://192.168.3.236:18308/v1/agent | |
107 | -pc.callcenter.url.openapiSurrogacyQuerycontacts=http://192.168.3.236:18308/v1/contacts/ | |
108 | -pc.callcenter.url.openapiCallGroupMember=http://192.168.3.236:18308/v1/contact/group_members/ | |
109 | -pc.callcenter.url.openapiSurrogacyAgent=http://192.168.3.236:18308/v1/agent | |
110 | -pc.callcenter.url.openapiSurrogacySendmessage=http://192.168.3.236:18308/v1/message_task | |
111 | -pc.callcenter.subscribeUrl=http://192.168.3.146/api/wxagentpcmessagesubscribe | |
112 | -pc.callcenter.url.sendMessageQueueName=oms-pc-msg | |
113 | -pc.callcenter.url.openapiContactsFeaturesgroup=http://192.168.3.236:18308/v1/contacts/ | |
114 | - | |
115 | -pc.message.url.messageTaskListUrl=http://192.168.3.236:18308/v1/message_task_list | |
116 | -pc.message.url.agentMessageTask=http://192.168.3.236:18308/v1/agent_message_task | |
117 | - | |
118 | -#cainiao param | |
119 | -cainiao.link.url=http://link.cainiao.com/gateway/link.do | |
120 | -cainiao.link.paramFormat=json | |
121 | -cainiao.link.appKey=650167 | |
122 | -cainiao.link.secretKey=lDO6y26nBJ6b5K96lnA1an447H1L0XK3 | |
123 | -cainiao.link.auth.grantpage=http://lcp.cloud.cainiao.com/permission/isv/grantpage.do | |
124 | -cainiao.link.auth.tokenUrl=http://lcp.cloud.cainiao.com/api/permission/exchangeToken.do | |
125 | -cainiao.link.auth.callbackUrl=https://api.oms.8zyun.cn/api/expressprint/auth/cainiao | |
126 | - | |
127 | -#fa wang | |
128 | -fineex.method.addOrder=fineex.wms.trades.add | |
129 | -fineex.method.cancelOrder=fineex.wms.trade.cancel | |
130 | -fineex.method.orderProcess=fineex.wms.trade.orderprocess.get | |
131 | -fineex.apiAddress=http://apicloud.fineex.net/Interface/InterfaceWeb/InterfaceFwWMS.ashx | |
132 | -fineex.method.goodsInventory=fineex.wms.product.inventory.get | |
133 | -fineex.method.orderConfirm=fineex.wms.trade.orderdetail.confirm | |
134 | -fineex.method.returnorderAdd=fineex.wms.trade.returnorder.add | |
135 | - | |
136 | - | |
137 | -qimen.api.appKey=30303007 | |
138 | -qimen.api.appSecret=80c63d1d8cf36a4c68b2df25fb93f703 | |
139 | -qimen.api.url=https://qimen.api.taobao.com/router/qmtest |
resources/application-production.properties
... | ... | @@ -1,74 +0,0 @@ |
1 | - | |
2 | -server.port=8200 | |
3 | -server.session.timeout=10 | |
4 | -server.connection-timeout=120000 | |
5 | - | |
6 | -spring.servlet.multipart.max-file-size=10MB | |
7 | -spring.servlet.multipart.max-request-size=20MB | |
8 | - | |
9 | -spring.jackson.time-zone=GMT+8 | |
10 | -spring.jackson.date-format=yyyy-MM-dd HH:mm:ss | |
11 | -spring.mvc.dateFormat = yyyy-MM-dd HH:mm:ss | |
12 | -spring.gson.serialize-nulls=true | |
13 | - | |
14 | -#email config | |
15 | -mail.host=smtp.taover.com | |
16 | -mail.port=25 | |
17 | -mail.username=taover-robot@taover.com | |
18 | -mail.password=Lexi@1798 | |
19 | -mail.smtp.auth=true | |
20 | -mail.smtp.sendFrom=taover-robot@taover.com | |
21 | - | |
22 | -#logback xml config | |
23 | -logging.config=classpath:logback-production.xml | |
24 | - | |
25 | -#allow http method options | |
26 | -spring.mvc.dispatch-options-request=true | |
27 | -spring.mvc.async.request-timeout=200000 | |
28 | - | |
29 | -#DB info | |
30 | -spring.datasource.url=jdbc:mysql://rdsifmezqifmezqo.mysql.rds.aliyuncs.com:3306/bzyun_wxorder_prd?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true | |
31 | -spring.datasource.username=tylife | |
32 | -spring.datasource.password=lexi365 | |
33 | -spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |
34 | -spring.datasource.max-idle=10 | |
35 | -spring.datasource.max-wait=10000 | |
36 | -spring.datasource.min-idle=5 | |
37 | -spring.datasource.initial-size=5 | |
38 | - | |
39 | -#zto analysis address url | |
40 | -zto.analysisAddress.url=https://hdgateway.zto.com/Word_AnalysisAddress | |
41 | -#taover analysis address url | |
42 | -taover.analysisAddress.url=http://address.taover.com/ | |
43 | -#kuaibao | |
44 | -kuaibao.analysisAddress.url=https://kop.kuaidihelp.com/api | |
45 | -kuaibao.analysisAddress.appId=105128 | |
46 | -kuaibao.analysisAddress.appKey=3310236ba4d6296e6e2346a7d9c824662510ff87 | |
47 | -kuaibao.analysisAddress.method=cloud.address.resolve | |
48 | -kuaibao.analysisAddress.methodSimple=cloud.address.cleanse | |
49 | - | |
50 | -#aliyun oss address | |
51 | -accessKeyId=H4fIVB56iHjR6zQw | |
52 | -accessKeySecret=7bA395UltFp16kWPJT7Pfz0XYXCk4Q | |
53 | -endpoint=oss-cn-beijing.aliyuncs.com | |
54 | -bucket_contact=8zyun-oss | |
55 | -aliyun.mnsEndpoint=http://1225610490807748.mns.cn-hangzhou.aliyuncs.com | |
56 | -#mobile message url | |
57 | -wwltData=sname=dlmzty00&spwd=A6cU4Tyx&scorpid=&sprdid=1012888 | |
58 | -wwltUrl=https://seccf.51welink.com/submitdata/service.asmx/g_Submit | |
59 | - | |
60 | -#pc api | |
61 | -pc.callcenter.url.openapiSurrogacyRegisteropenapi=https://ws.8zyun.cn:8080/v1/agent | |
62 | -pc.callcenter.url.openapiSurrogacyQuerycontacts=https://ws.8zyun.cn:8080/v1/contacts/ | |
63 | -pc.callcenter.url.openapiCallGroupMember=https://ws.8zyun.cn:8080/v1/contact/group_members/ | |
64 | -pc.callcenter.url.openapiSurrogacyAgent=https://ws.8zyun.cn:8080/v1/agent | |
65 | -pc.callcenter.url.openapiSurrogacySendmessage=https://ws.8zyun.cn:8080/v1/message_task | |
66 | -pc.callcenter.url.openapiContactsFeaturesgroup=https://ws.8zyun.cn:8080/v1/contactsMessageCount | |
67 | - | |
68 | -pc.callcenter.appid=c2MkSTjT8ghZ | |
69 | -pc.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0G | |
70 | -pc.callcenter.subscribeUrl=https://api.oms.8zyun.cn/api/wxagentpcmessagesubscribe | |
71 | -pc.callcenter.url.sendMessageQueueName=oms-pc-msg-production | |
72 | - | |
73 | -pc.message.url.messageTaskListUrl=https://ws.8zyun.cn:8080/v1/message_task_list | |
74 | -pc.message.url.agentMessageTask=https://ws.8zyun.cn:8080/v1/agent_message_task |
resources/application.properties
resources/logback-local.xml
... | ... | @@ -1,14 +0,0 @@ |
1 | -<configuration> | |
2 | - | |
3 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
4 | - encoders are assigned the type | |
5 | - ch.qos.logback.classic.encoder.PatternLayoutEncoder by default | |
6 | - <encoder> | |
7 | - <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
8 | - </encoder> | |
9 | - </appender> | |
10 | - | |
11 | - <root level="INFO"> | |
12 | - <appender-ref ref="STDOUT" /> | |
13 | - </root> | |
14 | -</configuration> |
resources/logback-production.xml
... | ... | @@ -1,59 +0,0 @@ |
1 | -<configuration> | |
2 | - | |
3 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
4 | - <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
5 | - <encoder> | |
6 | - <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
7 | - </encoder> | |
8 | - </appender> | |
9 | - | |
10 | - <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> | |
11 | - <smtpHost>smtp.taover.com</smtpHost> | |
12 | - <smtpPort>465</smtpPort> | |
13 | - <SSL>true</SSL> | |
14 | - <username>taover-robot@taover.com</username> | |
15 | - <password>Lexi@1798</password> | |
16 | - | |
17 | - <from>taover-robot@taover.com</from> | |
18 | - <to>wangbin@taover.com</to> | |
19 | - <to>gaoming@taover.com</to> | |
20 | - <to>liuyunpeng@taover.com</to> | |
21 | - <subject>八爪云-data-analysis/ERROR:%logger{20}</subject> | |
22 | - <layout class="ch.qos.logback.classic.html.HTMLLayout"/> | |
23 | - <!-- 这里采用等级过滤器,指定等级相符才发送,这里指定ERROR级别才发送 --> | |
24 | - <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |
25 | - <level>ERROR</level> | |
26 | - <onMatch>ACCEPT</onMatch> | |
27 | - <onMismatch>DENY</onMismatch> | |
28 | - </filter> | |
29 | - <!-- 每个电子邮件只发送一个日志条目 --> | |
30 | - <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker"> | |
31 | - <bufferSize>3</bufferSize> | |
32 | - </cyclicBufferTracker> | |
33 | - </appender> | |
34 | - | |
35 | - <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
36 | - <file>logback-rolling.log</file> | |
37 | - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
38 | - <!-- rollover daily --> | |
39 | - <fileNamePattern>logback-roll-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
40 | - <!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB --> | |
41 | - <maxFileSize>100MB</maxFileSize> | |
42 | - <maxHistory>60</maxHistory> | |
43 | - <totalSizeCap>5GB</totalSizeCap> | |
44 | - </rollingPolicy> | |
45 | - <encoder> | |
46 | - <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
47 | - </encoder> | |
48 | - </appender> | |
49 | - | |
50 | - <root level="ERROR"> | |
51 | - <appender-ref ref="EMAIL"/> | |
52 | - </root> | |
53 | - | |
54 | - <root level="INFO"> | |
55 | - <appender-ref ref="ROLLING"/> | |
56 | - <appender-ref ref="STDOUT" /> | |
57 | - </root> | |
58 | - | |
59 | -</configuration> |
src/com/taover/bazhuayun/analysis/script/goodscollect/GoodsDataFileParser.java
... | ... | @@ -1,68 +0,0 @@ |
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
... | ... | @@ -1,40 +0,0 @@ |
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
... | ... | @@ -1,160 +0,0 @@ |
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
... | ... | @@ -1,40 +0,0 @@ |
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
... | ... | @@ -1,65 +0,0 @@ |
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 | - public Integer getSenderNicknameIndex() { | |
42 | - return senderNicknameIndex; | |
43 | - } | |
44 | - public void setSenderNicknameIndex(Integer senderNicknameIndex) { | |
45 | - this.senderNicknameIndex = senderNicknameIndex; | |
46 | - } | |
47 | - public Integer getGroupNameIndex() { | |
48 | - return groupNameIndex; | |
49 | - } | |
50 | - public void setGroupNameIndex(Integer groupNameIndex) { | |
51 | - this.groupNameIndex = groupNameIndex; | |
52 | - } | |
53 | - public Integer getRoowWxidIndex() { | |
54 | - return roowWxidIndex; | |
55 | - } | |
56 | - public void setRoowWxidIndex(Integer roowWxidIndex) { | |
57 | - this.roowWxidIndex = roowWxidIndex; | |
58 | - } | |
59 | - public Integer getFielPathIndex() { | |
60 | - return fielPathIndex; | |
61 | - } | |
62 | - public void setFielPathIndex(Integer fielPathIndex) { | |
63 | - this.fielPathIndex = fielPathIndex; | |
64 | - } | |
65 | -} |
src/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelDataRow.java
... | ... | @@ -1,67 +0,0 @@ |
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
... | ... | @@ -1,74 +0,0 @@ |
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 dataDirPath = "C:\\Users\\Administrator\\Desktop\\悟空家数据核对-lff"; | |
25 | - String groupInfoFilePath = dataDirPath + File.separator + "groupinfo.csv"; | |
26 | - String goodsDataFileDirPath = dataDirPath + File.separator + "data"; | |
27 | - String logFilePath = dataDirPath + File.separator + "dealinfo.log"; | |
28 | - String resultDataFilePath = dataDirPath + File.separator + "result.xls"; | |
29 | - | |
30 | - //加载基础数据,文件来源 | |
31 | - GroupInfoExcelData groupInfoData = new GroupInfoExcelData(); | |
32 | - groupInfoData.load(groupInfoFilePath); | |
33 | - | |
34 | - //读取文件列表,交由解析器处理 | |
35 | - GoodsDataFileParser parser = new GoodsDataFileParser(goodsNamePatternArr, goodsSkuNameParrternArr, groupInfoData); | |
36 | - parser.setFileNameIgnorePreffix("【异常物流信息】-"); | |
37 | - parser.parse(groupInfoData, new File(goodsDataFileDirPath).listFiles()); | |
38 | - | |
39 | - //结果写入结果文件 | |
40 | - ExcelUtil.getWriter(new File(resultDataFilePath)).write(transListBeanTo2List(parser.getResult())).flush(); | |
41 | - | |
42 | - //执行信息写入日志文件 | |
43 | - FileUtil.writeString(parser.getLogString(), logFilePath, CharsetUtil.CHARSET_UTF_8); | |
44 | - } | |
45 | - | |
46 | - private static List<List<Object>> transListBeanTo2List(List<GoodsInfoRow> result) { | |
47 | - List<List<Object>> data = new ArrayList<List<Object>>(); | |
48 | - | |
49 | - //加入HEADER | |
50 | - List<Object> header = new ArrayList<Object>(); | |
51 | - header.add("原表名称"); | |
52 | - header.add("商品名称"); | |
53 | - header.add("原表规格"); | |
54 | - header.add("自选规格"); | |
55 | - header.add("仓库群名称"); | |
56 | - header.add("发文件的人"); | |
57 | - data.add(header); | |
58 | - | |
59 | - //加入BODY | |
60 | - for(int i=1; i<result.size(); ++i) { | |
61 | - GoodsInfoRow row = result.get(i); | |
62 | - List<Object> item = new ArrayList<Object>(); | |
63 | - item.add(row.getOriginGoodsName()); | |
64 | - item.add(row.getCommonGoodsName()); | |
65 | - item.add(row.getOriginGoodsSkuName()); | |
66 | - item.add(row.getCommonGoodsSkuName()); | |
67 | - item.add(row.getGroupNickname()); | |
68 | - item.add(row.getSenderNickname()); | |
69 | - data.add(item); | |
70 | - } | |
71 | - | |
72 | - return data; | |
73 | - } | |
74 | -} |
src/com/taover/bazhuayun/analysis/script/goodscollect/WindowMain.java
... | ... | @@ -1,56 +0,0 @@ |
1 | -package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | - | |
3 | -import java.awt.EventQueue; | |
4 | -import java.awt.event.ActionEvent; | |
5 | -import java.awt.event.ActionListener; | |
6 | - | |
7 | -import javax.swing.JFileChooser; | |
8 | -import javax.swing.JFrame; | |
9 | - | |
10 | -public class WindowMain { | |
11 | - | |
12 | - private JFrame frame; | |
13 | - | |
14 | - /** | |
15 | - * Launch the application. | |
16 | - */ | |
17 | - public static void main(String[] args) { | |
18 | - EventQueue.invokeLater(new Runnable() { | |
19 | - public void run() { | |
20 | - try { | |
21 | - WindowMain window = new WindowMain(); | |
22 | - window.frame.setVisible(true); | |
23 | - } catch (Exception e) { | |
24 | - e.printStackTrace(); | |
25 | - } | |
26 | - } | |
27 | - }); | |
28 | - } | |
29 | - | |
30 | - /** | |
31 | - * Create the application. | |
32 | - */ | |
33 | - public WindowMain() { | |
34 | - initialize(); | |
35 | - } | |
36 | - | |
37 | - /** | |
38 | - * Initialize the contents of the frame. | |
39 | - */ | |
40 | - private void initialize() { | |
41 | - frame = new JFrame(); | |
42 | - frame.setBounds(100, 100, 450, 300); | |
43 | - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
44 | - | |
45 | - JFileChooser chooser = new JFileChooser(); | |
46 | - chooser.setSize(200, 50); | |
47 | - chooser.addActionListener(new ActionListener() { | |
48 | - | |
49 | - @Override | |
50 | - public void actionPerformed(ActionEvent e) { | |
51 | - } | |
52 | - }); | |
53 | - frame.add(chooser); | |
54 | - } | |
55 | - | |
56 | -} |
src/com/taover/bazhuayun/analysis/script/orderdownload/Main.java
src/com/taover/bazhuayun/analysis/util/ExcelUtil.java
... | ... | @@ -1,146 +0,0 @@ |
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/FileContentTypeUtils.java
... | ... | @@ -1,83 +0,0 @@ |
1 | -package com.taover.bazhuayun.analysis.util; | |
2 | - | |
3 | -public class FileContentTypeUtils { | |
4 | - | |
5 | - public static String contentType(String filenameExtension) { | |
6 | - if (filenameExtension.equals(".BMP") || filenameExtension.equals(".bmp") | |
7 | - || filenameExtension.toUpperCase().equals(".BMP")) { | |
8 | - return "image/bmp"; | |
9 | - } | |
10 | - if (filenameExtension.equals(".GIF") || filenameExtension.equals(".gif") | |
11 | - || filenameExtension.toUpperCase().equals(".GIF")) { | |
12 | - return "image/gif"; | |
13 | - } | |
14 | - if (filenameExtension.equals(".JPEG") || filenameExtension.equals(".jpeg") || filenameExtension.equals(".JPG") | |
15 | - || filenameExtension.equals(".jpg") || filenameExtension.equals(".PNG") | |
16 | - || filenameExtension.equals(".png") || filenameExtension.toUpperCase().equals(".JPEG") | |
17 | - || filenameExtension.toUpperCase().equals(".JPG") || filenameExtension.toUpperCase().equals(".PNG")) { | |
18 | - return "image/jpeg"; | |
19 | - } | |
20 | - if (filenameExtension.equals(".HTML") || filenameExtension.equals(".html")) { | |
21 | - return "text/html"; | |
22 | - } | |
23 | - if (filenameExtension.equals(".TXT") || filenameExtension.equals(".txt") | |
24 | - || filenameExtension.toUpperCase().equals(".TXT")) { | |
25 | - return "text/plain"; | |
26 | - } | |
27 | - if (filenameExtension.equals(".VSD") || filenameExtension.equals(".vsd") | |
28 | - || filenameExtension.toUpperCase().equals(".VSD")) { | |
29 | - return "application/vnd.visio"; | |
30 | - } | |
31 | - if (filenameExtension.equals(".PPTX") || filenameExtension.equals(".pptx") || filenameExtension.equals(".PPT") | |
32 | - || filenameExtension.equals(".ppt") || filenameExtension.toUpperCase().equals(".PPTX") | |
33 | - || filenameExtension.toUpperCase().equals(".PPT")) { | |
34 | - return "application/vnd.ms-powerpoint"; | |
35 | - } | |
36 | - if (filenameExtension.equals(".DOCX") || filenameExtension.equals(".docx") || filenameExtension.equals(".DOC") | |
37 | - || filenameExtension.equals(".doc") || filenameExtension.toUpperCase().equals(".DOCX") | |
38 | - || filenameExtension.toUpperCase().equals(".DOC")) { | |
39 | - return "application/msword"; | |
40 | - } | |
41 | - if (filenameExtension.toUpperCase().equals(".XLSX")) { | |
42 | - return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; | |
43 | - } | |
44 | - if (filenameExtension.toUpperCase().equals(".XLS")) { | |
45 | - return "application/vnd.ms-excel"; | |
46 | - } | |
47 | - if (filenameExtension.equals(".XML") || filenameExtension.equals(".xml") | |
48 | - || filenameExtension.toUpperCase().equals(".XML")) { | |
49 | - return "text/xml"; | |
50 | - } | |
51 | - if (filenameExtension.equals(".pdf") || filenameExtension.equals(".PDF") | |
52 | - || filenameExtension.toUpperCase().equals(".PDF")) { | |
53 | - return "application/pdf"; | |
54 | - } | |
55 | - return null; | |
56 | - } | |
57 | - | |
58 | - public static String imgTypeValid(String dataPrix) { | |
59 | - if ("data:image/jpeg;".equalsIgnoreCase(dataPrix)) { | |
60 | - return ".jpeg"; | |
61 | - } else if ("data:image/jpg;".equalsIgnoreCase(dataPrix)) { | |
62 | - return ".jpg"; | |
63 | - } else if ("data:image/gif;".equalsIgnoreCase(dataPrix)) { | |
64 | - return ".gif"; | |
65 | - } else if ("data:image/png;".equalsIgnoreCase(dataPrix)) { | |
66 | - return ".png"; | |
67 | - } else if ("data:image/apng;".equalsIgnoreCase(dataPrix)) { | |
68 | - return ".apng"; | |
69 | - } else if ("data:image/svg;".equalsIgnoreCase(dataPrix)) { | |
70 | - return ".svg"; | |
71 | - } else if ("data:image/bmp;".equalsIgnoreCase(dataPrix)) { | |
72 | - return ".bmp"; | |
73 | - } | |
74 | - return null; | |
75 | - } | |
76 | - | |
77 | - public static String fileTypeValid(String dataPrix) { | |
78 | - if ("data:text/plain;".equalsIgnoreCase(dataPrix)) { | |
79 | - return ".txt"; | |
80 | - } | |
81 | - return null; | |
82 | - } | |
83 | -} |
src/com/taover/bazhuayun/analysis/util/StringTool.java
... | ... | @@ -1,193 +0,0 @@ |
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 | -} |
src/com/taover/bazhuayun/analysis/web/StartUp.java
... | ... | @@ -1,13 +0,0 @@ |
1 | -package com.taover.bazhuayun.analysis.web; | |
2 | - | |
3 | -import org.springframework.boot.SpringApplication; | |
4 | -import org.springframework.boot.autoconfigure.SpringBootApplication; | |
5 | -import org.springframework.context.annotation.EnableAspectJAutoProxy; | |
6 | - | |
7 | -@SpringBootApplication | |
8 | -@EnableAspectJAutoProxy(exposeProxy=true, proxyTargetClass=true) | |
9 | -public class StartUp { | |
10 | - public static void main(String[] args) { | |
11 | - SpringApplication.run(StartUp.class, args); | |
12 | - } | |
13 | -} | |
14 | 0 | \ No newline at end of file |
src/com/taover/bazhuayun/analysis/web/controller/ExportCenterController.java
... | ... | @@ -1,81 +0,0 @@ |
1 | -package com.taover.bazhuayun.analysis.web.controller; | |
2 | - | |
3 | -import java.io.File; | |
4 | -import java.io.FileInputStream; | |
5 | -import java.io.IOException; | |
6 | -import java.io.OutputStream; | |
7 | -import java.text.ParseException; | |
8 | -import java.text.SimpleDateFormat; | |
9 | -import java.util.Date; | |
10 | - | |
11 | -import javax.annotation.Resource; | |
12 | -import javax.servlet.http.HttpServletResponse; | |
13 | - | |
14 | -import org.apache.commons.lang.StringUtils; | |
15 | -import org.springframework.web.bind.annotation.GetMapping; | |
16 | -import org.springframework.web.bind.annotation.RequestMapping; | |
17 | -import org.springframework.web.bind.annotation.RequestParam; | |
18 | -import org.springframework.web.bind.annotation.RestController; | |
19 | - | |
20 | -import com.taover.bazhuayun.analysis.util.FileContentTypeUtils; | |
21 | -import com.taover.bazhuayun.analysis.web.service.ExportCenterService; | |
22 | -import com.taover.util.UtilLog; | |
23 | - | |
24 | -@RestController("exportcenter") | |
25 | -@RequestMapping("/exportcenter") | |
26 | -public class ExportCenterController { | |
27 | - @Resource | |
28 | - private ExportCenterService exportCenterService; | |
29 | - | |
30 | - @GetMapping("/wareorderfile") | |
31 | - public void wareOrderFile(@RequestParam(name="tenantId", required=true) Integer tenantId, | |
32 | - @RequestParam(name="startDate", defaultValue = "") String startDateStr, | |
33 | - @RequestParam(name="endDate", defaultValue = "") String endDateStr, | |
34 | - HttpServletResponse response) { | |
35 | - Date startDate = new Date(); | |
36 | - Date endDate = new Date(); | |
37 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
38 | - if(StringUtils.isNotBlank(startDateStr)) { | |
39 | - try { | |
40 | - startDate = sdf.parse(startDateStr.substring(0, 10)); | |
41 | - } catch (ParseException e) { | |
42 | - e.printStackTrace(); | |
43 | - } | |
44 | - } | |
45 | - if(StringUtils.isNotBlank(endDateStr)) { | |
46 | - try { | |
47 | - endDate = sdf.parse(endDateStr.substring(0, 10)); | |
48 | - } catch (ParseException e) { | |
49 | - e.printStackTrace(); | |
50 | - } | |
51 | - } | |
52 | - | |
53 | - File orderFile = null; | |
54 | - try { | |
55 | - orderFile = this.exportCenterService.wareOrderFile(tenantId, startDate, endDate); | |
56 | - } catch (IOException e1) { | |
57 | - UtilLog.errorForException(e1, this.getClass()); | |
58 | - return; | |
59 | - } | |
60 | - try { | |
61 | - this.writeFielToResponse(response, orderFile); | |
62 | - } catch (IOException e) { | |
63 | - UtilLog.errorForException(e, this.getClass()); | |
64 | - } | |
65 | - } | |
66 | - | |
67 | - private void writeFielToResponse(HttpServletResponse response, File file) throws IOException { | |
68 | - OutputStream stream = response.getOutputStream(); | |
69 | - FileInputStream reader = new FileInputStream(file); | |
70 | - byte[] data= new byte[(int)file.length()]; | |
71 | - reader.read(data); | |
72 | - reader.close(); | |
73 | - | |
74 | - //记得设置ContentType | |
75 | - String fileName = file.getName(); | |
76 | - response.setContentType(FileContentTypeUtils.contentType(fileName.substring(fileName.lastIndexOf(".")))); | |
77 | - response.setHeader("Content-Dis", "filename="+file.getName()); | |
78 | - stream.write(data); | |
79 | - stream.flush(); | |
80 | - } | |
81 | -} |
src/com/taover/bazhuayun/analysis/web/service/ExportCenterService.java
... | ... | @@ -1,72 +0,0 @@ |
1 | -package com.taover.bazhuayun.analysis.web.service; | |
2 | - | |
3 | -import java.io.File; | |
4 | -import java.io.IOException; | |
5 | -import java.text.SimpleDateFormat; | |
6 | -import java.util.ArrayList; | |
7 | -import java.util.Date; | |
8 | -import java.util.List; | |
9 | -import java.util.Map; | |
10 | - | |
11 | -import javax.annotation.Resource; | |
12 | - | |
13 | -import org.springframework.jdbc.core.JdbcTemplate; | |
14 | -import org.springframework.stereotype.Service; | |
15 | - | |
16 | -import cn.hutool.poi.excel.ExcelUtil; | |
17 | - | |
18 | -@Service | |
19 | -public class ExportCenterService { | |
20 | - @Resource | |
21 | - private JdbcTemplate jdbcTemplate; | |
22 | - | |
23 | - public File wareOrderFile(Integer tenantId, Date startDate, Date endDate) throws IOException { | |
24 | - //查询agentID | |
25 | - String agentIdQuery = "select agent_id from wxorder_agent_pc where tenant_id="+tenantId+" limit 1 "; | |
26 | - Integer agentId = this.jdbcTemplate.queryForObject(agentIdQuery, Integer.class); | |
27 | - | |
28 | - //查询仓库对应群列表 | |
29 | - String wareGroupQuery = "select wx_group_ssid,wx_group_nickname,name from wxorder_ware where tenant_id="+tenantId; | |
30 | - List<Map<String, Object>> groupData = this.jdbcTemplate.queryForList(wareGroupQuery); | |
31 | - | |
32 | - //依据群id,获取数据列表 | |
33 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
34 | - String startDateStr = sdf.format(startDate)+" 00:00:00"; | |
35 | - String endDateStr = sdf.format(endDate)+" 00:00:00"; | |
36 | - List<Map<String, Object>> messageData = new ArrayList<Map<String, Object>>(); | |
37 | - String messageQuery = "select room_wxid,sender_nickname,created_at,file_path from bzyun_wechat.messages where created_at>'"+startDateStr+"' and created_at<'"+endDateStr+"' and agent_id="+agentId+" and kind='FILE' and file_path not like '%【异常物流信息】%' and recall=0 and room_wxid=? "; | |
38 | - for(Map<String, Object> item: groupData) { | |
39 | - String wxGroupSsid = item.get("wx_group_ssid").toString(); | |
40 | - List<Map<String, Object>> itemData = this.jdbcTemplate.queryForList(messageQuery, wxGroupSsid); | |
41 | - for(Map<String, Object> messageItem: itemData) { | |
42 | - messageItem.putAll(item); | |
43 | - } | |
44 | - messageData.addAll(itemData); | |
45 | - } | |
46 | - | |
47 | - //生成本地excel文件 | |
48 | - List<List<Object>> data = new ArrayList<List<Object>>(); | |
49 | - List<Object> headerData = new ArrayList<Object>(); | |
50 | - headerData.add("群名称"); | |
51 | - headerData.add("room_wxid"); | |
52 | - headerData.add("创建时间"); | |
53 | - headerData.add("发送人昵称"); | |
54 | - headerData.add("文件路径"); | |
55 | - headerData.add("仓库名称"); | |
56 | - data.add(headerData); | |
57 | - for(Map<String, Object> item: messageData) { | |
58 | - List<Object> itemData = new ArrayList<Object>(); | |
59 | - itemData.add(item.get("wx_group_nickname")); | |
60 | - itemData.add(item.get("room_wxid")); | |
61 | - itemData.add(item.get("created_at")); | |
62 | - itemData.add(item.get("sender_nickname")); | |
63 | - itemData.add(item.get("file_path")); | |
64 | - itemData.add(item.get("name")); | |
65 | - data.add(itemData); | |
66 | - } | |
67 | - File excelFile = File.createTempFile("wareorderfile", ".xlsx"); | |
68 | - ExcelUtil.getWriter(true).write(data).flush(excelFile); | |
69 | - return excelFile; | |
70 | - } | |
71 | - | |
72 | -} |
src/main/java/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/main/java/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/main/java/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/main/java/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/main/java/com/taover/bazhuayun/analysis/script/goodscollect/GroupInfoExcelDataHeader.java
0 → 100644
... | ... | @@ -0,0 +1,65 @@ |
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 | + public Integer getSenderNicknameIndex() { | |
42 | + return senderNicknameIndex; | |
43 | + } | |
44 | + public void setSenderNicknameIndex(Integer senderNicknameIndex) { | |
45 | + this.senderNicknameIndex = senderNicknameIndex; | |
46 | + } | |
47 | + public Integer getGroupNameIndex() { | |
48 | + return groupNameIndex; | |
49 | + } | |
50 | + public void setGroupNameIndex(Integer groupNameIndex) { | |
51 | + this.groupNameIndex = groupNameIndex; | |
52 | + } | |
53 | + public Integer getRoowWxidIndex() { | |
54 | + return roowWxidIndex; | |
55 | + } | |
56 | + public void setRoowWxidIndex(Integer roowWxidIndex) { | |
57 | + this.roowWxidIndex = roowWxidIndex; | |
58 | + } | |
59 | + public Integer getFielPathIndex() { | |
60 | + return fielPathIndex; | |
61 | + } | |
62 | + public void setFielPathIndex(Integer fielPathIndex) { | |
63 | + this.fielPathIndex = fielPathIndex; | |
64 | + } | |
65 | +} | ... | ... |
src/main/java/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/main/java/com/taover/bazhuayun/analysis/script/goodscollect/Main.java
0 → 100644
... | ... | @@ -0,0 +1,74 @@ |
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 dataDirPath = "C:\\Users\\Administrator\\Desktop\\悟空家数据核对-lff"; | |
25 | + String groupInfoFilePath = dataDirPath + File.separator + "groupinfo.csv"; | |
26 | + String goodsDataFileDirPath = dataDirPath + File.separator + "data"; | |
27 | + String logFilePath = dataDirPath + File.separator + "dealinfo.log"; | |
28 | + String resultDataFilePath = dataDirPath + File.separator + "result.xls"; | |
29 | + | |
30 | + //加载基础数据,文件来源 | |
31 | + GroupInfoExcelData groupInfoData = new GroupInfoExcelData(); | |
32 | + groupInfoData.load(groupInfoFilePath); | |
33 | + | |
34 | + //读取文件列表,交由解析器处理 | |
35 | + GoodsDataFileParser parser = new GoodsDataFileParser(goodsNamePatternArr, goodsSkuNameParrternArr, groupInfoData); | |
36 | + parser.setFileNameIgnorePreffix("【异常物流信息】-"); | |
37 | + parser.parse(groupInfoData, new File(goodsDataFileDirPath).listFiles()); | |
38 | + | |
39 | + //结果写入结果文件 | |
40 | + ExcelUtil.getWriter(new File(resultDataFilePath)).write(transListBeanTo2List(parser.getResult())).flush(); | |
41 | + | |
42 | + //执行信息写入日志文件 | |
43 | + FileUtil.writeString(parser.getLogString(), logFilePath, CharsetUtil.CHARSET_UTF_8); | |
44 | + } | |
45 | + | |
46 | + private static List<List<Object>> transListBeanTo2List(List<GoodsInfoRow> result) { | |
47 | + List<List<Object>> data = new ArrayList<List<Object>>(); | |
48 | + | |
49 | + //加入HEADER | |
50 | + List<Object> header = new ArrayList<Object>(); | |
51 | + header.add("原表名称"); | |
52 | + header.add("商品名称"); | |
53 | + header.add("原表规格"); | |
54 | + header.add("自选规格"); | |
55 | + header.add("仓库群名称"); | |
56 | + header.add("发文件的人"); | |
57 | + data.add(header); | |
58 | + | |
59 | + //加入BODY | |
60 | + for(int i=1; i<result.size(); ++i) { | |
61 | + GoodsInfoRow row = result.get(i); | |
62 | + List<Object> item = new ArrayList<Object>(); | |
63 | + item.add(row.getOriginGoodsName()); | |
64 | + item.add(row.getCommonGoodsName()); | |
65 | + item.add(row.getOriginGoodsSkuName()); | |
66 | + item.add(row.getCommonGoodsSkuName()); | |
67 | + item.add(row.getGroupNickname()); | |
68 | + item.add(row.getSenderNickname()); | |
69 | + data.add(item); | |
70 | + } | |
71 | + | |
72 | + return data; | |
73 | + } | |
74 | +} | ... | ... |
src/main/java/com/taover/bazhuayun/analysis/script/goodscollect/WindowMain.java
0 → 100644
... | ... | @@ -0,0 +1,56 @@ |
1 | +package com.taover.bazhuayun.analysis.script.goodscollect; | |
2 | + | |
3 | +import java.awt.EventQueue; | |
4 | +import java.awt.event.ActionEvent; | |
5 | +import java.awt.event.ActionListener; | |
6 | + | |
7 | +import javax.swing.JFileChooser; | |
8 | +import javax.swing.JFrame; | |
9 | + | |
10 | +public class WindowMain { | |
11 | + | |
12 | + private JFrame frame; | |
13 | + | |
14 | + /** | |
15 | + * Launch the application. | |
16 | + */ | |
17 | + public static void main(String[] args) { | |
18 | + EventQueue.invokeLater(new Runnable() { | |
19 | + public void run() { | |
20 | + try { | |
21 | + WindowMain window = new WindowMain(); | |
22 | + window.frame.setVisible(true); | |
23 | + } catch (Exception e) { | |
24 | + e.printStackTrace(); | |
25 | + } | |
26 | + } | |
27 | + }); | |
28 | + } | |
29 | + | |
30 | + /** | |
31 | + * Create the application. | |
32 | + */ | |
33 | + public WindowMain() { | |
34 | + initialize(); | |
35 | + } | |
36 | + | |
37 | + /** | |
38 | + * Initialize the contents of the frame. | |
39 | + */ | |
40 | + private void initialize() { | |
41 | + frame = new JFrame(); | |
42 | + frame.setBounds(100, 100, 450, 300); | |
43 | + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
44 | + | |
45 | + JFileChooser chooser = new JFileChooser(); | |
46 | + chooser.setSize(200, 50); | |
47 | + chooser.addActionListener(new ActionListener() { | |
48 | + | |
49 | + @Override | |
50 | + public void actionPerformed(ActionEvent e) { | |
51 | + } | |
52 | + }); | |
53 | + frame.add(chooser); | |
54 | + } | |
55 | + | |
56 | +} | ... | ... |
src/main/java/com/taover/bazhuayun/analysis/script/orderdownload/Main.java
0 → 100644
src/main/java/com/taover/bazhuayun/analysis/util/ExcelUtil.java
0 → 100644
... | ... | @@ -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/main/java/com/taover/bazhuayun/analysis/util/FileContentTypeUtils.java
0 → 100644
... | ... | @@ -0,0 +1,83 @@ |
1 | +package com.taover.bazhuayun.analysis.util; | |
2 | + | |
3 | +public class FileContentTypeUtils { | |
4 | + | |
5 | + public static String contentType(String filenameExtension) { | |
6 | + if (filenameExtension.equals(".BMP") || filenameExtension.equals(".bmp") | |
7 | + || filenameExtension.toUpperCase().equals(".BMP")) { | |
8 | + return "image/bmp"; | |
9 | + } | |
10 | + if (filenameExtension.equals(".GIF") || filenameExtension.equals(".gif") | |
11 | + || filenameExtension.toUpperCase().equals(".GIF")) { | |
12 | + return "image/gif"; | |
13 | + } | |
14 | + if (filenameExtension.equals(".JPEG") || filenameExtension.equals(".jpeg") || filenameExtension.equals(".JPG") | |
15 | + || filenameExtension.equals(".jpg") || filenameExtension.equals(".PNG") | |
16 | + || filenameExtension.equals(".png") || filenameExtension.toUpperCase().equals(".JPEG") | |
17 | + || filenameExtension.toUpperCase().equals(".JPG") || filenameExtension.toUpperCase().equals(".PNG")) { | |
18 | + return "image/jpeg"; | |
19 | + } | |
20 | + if (filenameExtension.equals(".HTML") || filenameExtension.equals(".html")) { | |
21 | + return "text/html"; | |
22 | + } | |
23 | + if (filenameExtension.equals(".TXT") || filenameExtension.equals(".txt") | |
24 | + || filenameExtension.toUpperCase().equals(".TXT")) { | |
25 | + return "text/plain"; | |
26 | + } | |
27 | + if (filenameExtension.equals(".VSD") || filenameExtension.equals(".vsd") | |
28 | + || filenameExtension.toUpperCase().equals(".VSD")) { | |
29 | + return "application/vnd.visio"; | |
30 | + } | |
31 | + if (filenameExtension.equals(".PPTX") || filenameExtension.equals(".pptx") || filenameExtension.equals(".PPT") | |
32 | + || filenameExtension.equals(".ppt") || filenameExtension.toUpperCase().equals(".PPTX") | |
33 | + || filenameExtension.toUpperCase().equals(".PPT")) { | |
34 | + return "application/vnd.ms-powerpoint"; | |
35 | + } | |
36 | + if (filenameExtension.equals(".DOCX") || filenameExtension.equals(".docx") || filenameExtension.equals(".DOC") | |
37 | + || filenameExtension.equals(".doc") || filenameExtension.toUpperCase().equals(".DOCX") | |
38 | + || filenameExtension.toUpperCase().equals(".DOC")) { | |
39 | + return "application/msword"; | |
40 | + } | |
41 | + if (filenameExtension.toUpperCase().equals(".XLSX")) { | |
42 | + return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; | |
43 | + } | |
44 | + if (filenameExtension.toUpperCase().equals(".XLS")) { | |
45 | + return "application/vnd.ms-excel"; | |
46 | + } | |
47 | + if (filenameExtension.equals(".XML") || filenameExtension.equals(".xml") | |
48 | + || filenameExtension.toUpperCase().equals(".XML")) { | |
49 | + return "text/xml"; | |
50 | + } | |
51 | + if (filenameExtension.equals(".pdf") || filenameExtension.equals(".PDF") | |
52 | + || filenameExtension.toUpperCase().equals(".PDF")) { | |
53 | + return "application/pdf"; | |
54 | + } | |
55 | + return null; | |
56 | + } | |
57 | + | |
58 | + public static String imgTypeValid(String dataPrix) { | |
59 | + if ("data:image/jpeg;".equalsIgnoreCase(dataPrix)) { | |
60 | + return ".jpeg"; | |
61 | + } else if ("data:image/jpg;".equalsIgnoreCase(dataPrix)) { | |
62 | + return ".jpg"; | |
63 | + } else if ("data:image/gif;".equalsIgnoreCase(dataPrix)) { | |
64 | + return ".gif"; | |
65 | + } else if ("data:image/png;".equalsIgnoreCase(dataPrix)) { | |
66 | + return ".png"; | |
67 | + } else if ("data:image/apng;".equalsIgnoreCase(dataPrix)) { | |
68 | + return ".apng"; | |
69 | + } else if ("data:image/svg;".equalsIgnoreCase(dataPrix)) { | |
70 | + return ".svg"; | |
71 | + } else if ("data:image/bmp;".equalsIgnoreCase(dataPrix)) { | |
72 | + return ".bmp"; | |
73 | + } | |
74 | + return null; | |
75 | + } | |
76 | + | |
77 | + public static String fileTypeValid(String dataPrix) { | |
78 | + if ("data:text/plain;".equalsIgnoreCase(dataPrix)) { | |
79 | + return ".txt"; | |
80 | + } | |
81 | + return null; | |
82 | + } | |
83 | +} | ... | ... |
src/main/java/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 | +} | ... | ... |
src/main/java/com/taover/bazhuayun/analysis/web/StartUp.java
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +package com.taover.bazhuayun.analysis.web; | |
2 | + | |
3 | +import org.springframework.boot.SpringApplication; | |
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
5 | +import org.springframework.context.annotation.EnableAspectJAutoProxy; | |
6 | + | |
7 | +@SpringBootApplication | |
8 | +@EnableAspectJAutoProxy(exposeProxy=true, proxyTargetClass=true) | |
9 | +public class StartUp { | |
10 | + public static void main(String[] args) { | |
11 | + SpringApplication.run(StartUp.class, args); | |
12 | + } | |
13 | +} | |
0 | 14 | \ No newline at end of file | ... | ... |
src/main/java/com/taover/bazhuayun/analysis/web/controller/ExportCenterController.java
0 → 100644
... | ... | @@ -0,0 +1,81 @@ |
1 | +package com.taover.bazhuayun.analysis.web.controller; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.io.FileInputStream; | |
5 | +import java.io.IOException; | |
6 | +import java.io.OutputStream; | |
7 | +import java.text.ParseException; | |
8 | +import java.text.SimpleDateFormat; | |
9 | +import java.util.Date; | |
10 | + | |
11 | +import javax.annotation.Resource; | |
12 | +import javax.servlet.http.HttpServletResponse; | |
13 | + | |
14 | +import org.apache.commons.lang.StringUtils; | |
15 | +import org.springframework.web.bind.annotation.GetMapping; | |
16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
17 | +import org.springframework.web.bind.annotation.RequestParam; | |
18 | +import org.springframework.web.bind.annotation.RestController; | |
19 | + | |
20 | +import com.taover.bazhuayun.analysis.util.FileContentTypeUtils; | |
21 | +import com.taover.bazhuayun.analysis.web.service.ExportCenterService; | |
22 | +import com.taover.util.UtilLog; | |
23 | + | |
24 | +@RestController("exportcenter") | |
25 | +@RequestMapping("/exportcenter") | |
26 | +public class ExportCenterController { | |
27 | + @Resource | |
28 | + private ExportCenterService exportCenterService; | |
29 | + | |
30 | + @GetMapping("/wareorderfile") | |
31 | + public void wareOrderFile(@RequestParam(name="tenantId", required=true) Integer tenantId, | |
32 | + @RequestParam(name="startDate", defaultValue = "") String startDateStr, | |
33 | + @RequestParam(name="endDate", defaultValue = "") String endDateStr, | |
34 | + HttpServletResponse response) { | |
35 | + Date startDate = new Date(); | |
36 | + Date endDate = new Date(); | |
37 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
38 | + if(StringUtils.isNotBlank(startDateStr)) { | |
39 | + try { | |
40 | + startDate = sdf.parse(startDateStr.substring(0, 10)); | |
41 | + } catch (ParseException e) { | |
42 | + e.printStackTrace(); | |
43 | + } | |
44 | + } | |
45 | + if(StringUtils.isNotBlank(endDateStr)) { | |
46 | + try { | |
47 | + endDate = sdf.parse(endDateStr.substring(0, 10)); | |
48 | + } catch (ParseException e) { | |
49 | + e.printStackTrace(); | |
50 | + } | |
51 | + } | |
52 | + | |
53 | + File orderFile = null; | |
54 | + try { | |
55 | + orderFile = this.exportCenterService.wareOrderFile(tenantId, startDate, endDate); | |
56 | + } catch (IOException e1) { | |
57 | + UtilLog.errorForException(e1, this.getClass()); | |
58 | + return; | |
59 | + } | |
60 | + try { | |
61 | + this.writeFielToResponse(response, orderFile); | |
62 | + } catch (IOException e) { | |
63 | + UtilLog.errorForException(e, this.getClass()); | |
64 | + } | |
65 | + } | |
66 | + | |
67 | + private void writeFielToResponse(HttpServletResponse response, File file) throws IOException { | |
68 | + OutputStream stream = response.getOutputStream(); | |
69 | + FileInputStream reader = new FileInputStream(file); | |
70 | + byte[] data= new byte[(int)file.length()]; | |
71 | + reader.read(data); | |
72 | + reader.close(); | |
73 | + | |
74 | + //记得设置ContentType | |
75 | + String fileName = file.getName(); | |
76 | + response.setContentType(FileContentTypeUtils.contentType(fileName.substring(fileName.lastIndexOf(".")))); | |
77 | + response.setHeader("Content-Dis", "filename="+file.getName()); | |
78 | + stream.write(data); | |
79 | + stream.flush(); | |
80 | + } | |
81 | +} | ... | ... |
src/main/java/com/taover/bazhuayun/analysis/web/service/ExportCenterService.java
0 → 100644
... | ... | @@ -0,0 +1,72 @@ |
1 | +package com.taover.bazhuayun.analysis.web.service; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.io.IOException; | |
5 | +import java.text.SimpleDateFormat; | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.Date; | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | + | |
11 | +import javax.annotation.Resource; | |
12 | + | |
13 | +import org.springframework.jdbc.core.JdbcTemplate; | |
14 | +import org.springframework.stereotype.Service; | |
15 | + | |
16 | +import cn.hutool.poi.excel.ExcelUtil; | |
17 | + | |
18 | +@Service | |
19 | +public class ExportCenterService { | |
20 | + @Resource | |
21 | + private JdbcTemplate jdbcTemplate; | |
22 | + | |
23 | + public File wareOrderFile(Integer tenantId, Date startDate, Date endDate) throws IOException { | |
24 | + //查询agentID | |
25 | + String agentIdQuery = "select agent_id from wxorder_agent_pc where tenant_id="+tenantId+" limit 1 "; | |
26 | + Integer agentId = this.jdbcTemplate.queryForObject(agentIdQuery, Integer.class); | |
27 | + | |
28 | + //查询仓库对应群列表 | |
29 | + String wareGroupQuery = "select wx_group_ssid,wx_group_nickname,name from wxorder_ware where tenant_id="+tenantId; | |
30 | + List<Map<String, Object>> groupData = this.jdbcTemplate.queryForList(wareGroupQuery); | |
31 | + | |
32 | + //依据群id,获取数据列表 | |
33 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
34 | + String startDateStr = sdf.format(startDate)+" 00:00:00"; | |
35 | + String endDateStr = sdf.format(endDate)+" 00:00:00"; | |
36 | + List<Map<String, Object>> messageData = new ArrayList<Map<String, Object>>(); | |
37 | + String messageQuery = "select room_wxid,sender_nickname,created_at,file_path from bzyun_wechat.messages where created_at>'"+startDateStr+"' and created_at<'"+endDateStr+"' and agent_id="+agentId+" and kind='FILE' and file_path not like '%【异常物流信息】%' and recall=0 and room_wxid=? "; | |
38 | + for(Map<String, Object> item: groupData) { | |
39 | + String wxGroupSsid = item.get("wx_group_ssid").toString(); | |
40 | + List<Map<String, Object>> itemData = this.jdbcTemplate.queryForList(messageQuery, wxGroupSsid); | |
41 | + for(Map<String, Object> messageItem: itemData) { | |
42 | + messageItem.putAll(item); | |
43 | + } | |
44 | + messageData.addAll(itemData); | |
45 | + } | |
46 | + | |
47 | + //生成本地excel文件 | |
48 | + List<List<Object>> data = new ArrayList<List<Object>>(); | |
49 | + List<Object> headerData = new ArrayList<Object>(); | |
50 | + headerData.add("群名称"); | |
51 | + headerData.add("room_wxid"); | |
52 | + headerData.add("创建时间"); | |
53 | + headerData.add("发送人昵称"); | |
54 | + headerData.add("文件路径"); | |
55 | + headerData.add("仓库名称"); | |
56 | + data.add(headerData); | |
57 | + for(Map<String, Object> item: messageData) { | |
58 | + List<Object> itemData = new ArrayList<Object>(); | |
59 | + itemData.add(item.get("wx_group_nickname")); | |
60 | + itemData.add(item.get("room_wxid")); | |
61 | + itemData.add(item.get("created_at")); | |
62 | + itemData.add(item.get("sender_nickname")); | |
63 | + itemData.add(item.get("file_path")); | |
64 | + itemData.add(item.get("name")); | |
65 | + data.add(itemData); | |
66 | + } | |
67 | + File excelFile = File.createTempFile("wareorderfile", ".xlsx"); | |
68 | + ExcelUtil.getWriter(true).write(data).flush(excelFile); | |
69 | + return excelFile; | |
70 | + } | |
71 | + | |
72 | +} | ... | ... |
... | ... | @@ -0,0 +1,139 @@ |
1 | + | |
2 | +server.port=80 | |
3 | +server.session.timeout=10 | |
4 | + | |
5 | +spring.servlet.multipart.max-file-size=10MB | |
6 | +spring.servlet.multipart.max-request-size=20MB | |
7 | + | |
8 | +spring.jackson.time-zone=GMT+8 | |
9 | +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss | |
10 | +spring.mvc.dateFormat = yyyy-MM-dd HH:mm:ss | |
11 | +spring.gson.serialize-nulls=true | |
12 | + | |
13 | +tokenfilter.enable=false | |
14 | + | |
15 | +logging.config=classpath:logback-local.xml | |
16 | + | |
17 | + | |
18 | +mail.host=smtp.taover.com | |
19 | +mail.port=25 | |
20 | +mail.username=taover-robot@taover.com | |
21 | +mail.password=Lexi@1798 | |
22 | +mail.smtp.auth=true | |
23 | +mail.smtp.sendFrom=taover-robot@taover.com | |
24 | + | |
25 | +spring.mvc.dispatch-options-request=true | |
26 | + | |
27 | +#spring.datasource.url=jdbc\:mysql\://192.168.3.189\:3306/8zyun_wxorder?useUnicode\=true&characterEncoding\=UTF-8&autoReconnect\=true&zeroDateTimeBehavior\=convertToNull&transformedBitIsBoolean\=true | |
28 | +#spring.datasource.username=root | |
29 | +#spring.datasource.password=root | |
30 | + | |
31 | + | |
32 | +spring.datasource.url=jdbc\:mysql\://121.42.142.102\:3306/bzyun_wxorder?useUnicode\=true&characterEncoding\=UTF-8&autoReconnect\=true&zeroDateTimeBehavior\=convertToNull&transformedBitIsBoolean\=true | |
33 | +spring.datasource.username=dev | |
34 | +spring.datasource.password=taover02 | |
35 | +spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |
36 | +spring.datasource.max-idle=10 | |
37 | +spring.datasource.max-wait=10000 | |
38 | +spring.datasource.min-idle=5 | |
39 | +spring.datasource.initial-size=5 | |
40 | + | |
41 | +#zto analysis address url | |
42 | +#zto.analysisAddress.url=https://localhost/Word_AnalysisAddress | |
43 | +zto.analysisAddress.url=https://hdgateway.zto.com/Word_AnalysisAddress | |
44 | +#taover analysis address url | |
45 | +taover.analysisAddress.url=http://address.taover.com/ | |
46 | +#kuaibao | |
47 | +kuaibao.analysisAddress.url=https://kop.kuaidihelp.com/api | |
48 | +kuaibao.analysisAddress.appId=105128 | |
49 | +kuaibao.analysisAddress.appKey=3310236ba4d6296e6e2346a7d9c824662510ff87 | |
50 | +kuaibao.analysisAddress.method=cloud.address.resolve | |
51 | +kuaibao.analysisAddress.methodSimple=cloud.address.cleanse | |
52 | + | |
53 | +#aliyun oss | |
54 | +accessKeyId=H4fIVB56iHjR6zQw | |
55 | +accessKeySecret=7bA395UltFp16kWPJT7Pfz0XYXCk4Q | |
56 | +endpoint=oss-cn-beijing.aliyuncs.com | |
57 | +bucket_contact=8zyun-oss | |
58 | +aliyun.mnsEndpoint=http://1225610490807748.mns.cn-hangzhou.aliyuncs.com | |
59 | +#https://8zyun-oss.oss-cn-beijing.aliyuncs.com | |
60 | +#mobile message url | |
61 | +wwltData=sname=dlmzty00&spwd=A6cU4Tyx&scorpid=&sprdid=1012888 | |
62 | +wwltUrl=https://seccf.51welink.com/submitdata/service.asmx/g_Submit | |
63 | + | |
64 | +#root ssy callcenter api config | |
65 | +ssy.callcenter.appid=c2MkSTjT8ghM | |
66 | +ssy.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0f | |
67 | + | |
68 | +pc.callcenter.appid=c2MkSTjT8ghZ | |
69 | +pc.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0G | |
70 | + | |
71 | +ssy.callcenter.subscribePreffixUrl=http://localhost/api/ | |
72 | +ssy.callcenter.subscribeSuffixUrl=/wxagentssymessagesubscribe | |
73 | + | |
74 | + | |
75 | +ssy.callcenter.url.openapiSurrogacyAgent=/api/v2/openapi/surrogacy/agent | |
76 | +ssy.callcenter.url.openapiSurrogacyQuerycontacts=/api/v2/openapi/surrogacy/querycontacts | |
77 | +ssy.callcenter.url.openapiSurrogacySendmessage=/api/v2/openapi/surrogacy/sendmessage | |
78 | +ssy.callcenter.url.openapiSurrogacyRegisteropenapi=/api/v2/openapi/surrogacy/registeropenapi | |
79 | +ssy.callcenter.url.openapiSurrogacyUnregisteropenapi=/api/v2/openapi/surrogacy/unregisteropenapi | |
80 | +ssy.callcenter.url.openapiCallcenterapibridgeService=/api/v2/openapi/callcenterapibridge/service | |
81 | +ssy.callcenter.url.openapiCallGroupMember=/api/v2/openapi/surrogacy/querygroupmember | |
82 | + | |
83 | + | |
84 | + | |
85 | + | |
86 | +ssy.upload.url=https://ssep.umsapi.com/api/v1/upload | |
87 | + | |
88 | +ssy.callcenter.sendMessage.preffixUrl=https://ssep.umsapi.com | |
89 | + | |
90 | +#weixin group text order confirm url | |
91 | +wxorder.url.grouptextorder.confirm=http://localhost:8100/confirm/ | |
92 | +wxorder.url.express.search=http://localhost:8100/confirm/query-logistics/ | |
93 | + | |
94 | +#ssy file server domain | |
95 | +ssy.fileserver.urlpreffix=https://ss0.umsapi.com | |
96 | + | |
97 | +wxorder.front.url.host=http://localhost:8100 | |
98 | + | |
99 | +platform.shop.registerUrl=http://localhost/common/authorization/index | |
100 | + | |
101 | +wxorder.platformgoods.matchurl=http://localhost/goods/channelgoods | |
102 | +wxorder.platformgoods.errororderurl=https://localhost/ordererror/index | |
103 | +wxorder.url.excellist=http://localhost/groupexcel/index | |
104 | + | |
105 | +#pc api | |
106 | +pc.callcenter.url.openapiSurrogacyRegisteropenapi=http://192.168.3.236:18308/v1/agent | |
107 | +pc.callcenter.url.openapiSurrogacyQuerycontacts=http://192.168.3.236:18308/v1/contacts/ | |
108 | +pc.callcenter.url.openapiCallGroupMember=http://192.168.3.236:18308/v1/contact/group_members/ | |
109 | +pc.callcenter.url.openapiSurrogacyAgent=http://192.168.3.236:18308/v1/agent | |
110 | +pc.callcenter.url.openapiSurrogacySendmessage=http://192.168.3.236:18308/v1/message_task | |
111 | +pc.callcenter.subscribeUrl=http://192.168.3.146/api/wxagentpcmessagesubscribe | |
112 | +pc.callcenter.url.sendMessageQueueName=oms-pc-msg | |
113 | +pc.callcenter.url.openapiContactsFeaturesgroup=http://192.168.3.236:18308/v1/contacts/ | |
114 | + | |
115 | +pc.message.url.messageTaskListUrl=http://192.168.3.236:18308/v1/message_task_list | |
116 | +pc.message.url.agentMessageTask=http://192.168.3.236:18308/v1/agent_message_task | |
117 | + | |
118 | +#cainiao param | |
119 | +cainiao.link.url=http://link.cainiao.com/gateway/link.do | |
120 | +cainiao.link.paramFormat=json | |
121 | +cainiao.link.appKey=650167 | |
122 | +cainiao.link.secretKey=lDO6y26nBJ6b5K96lnA1an447H1L0XK3 | |
123 | +cainiao.link.auth.grantpage=http://lcp.cloud.cainiao.com/permission/isv/grantpage.do | |
124 | +cainiao.link.auth.tokenUrl=http://lcp.cloud.cainiao.com/api/permission/exchangeToken.do | |
125 | +cainiao.link.auth.callbackUrl=https://api.oms.8zyun.cn/api/expressprint/auth/cainiao | |
126 | + | |
127 | +#fa wang | |
128 | +fineex.method.addOrder=fineex.wms.trades.add | |
129 | +fineex.method.cancelOrder=fineex.wms.trade.cancel | |
130 | +fineex.method.orderProcess=fineex.wms.trade.orderprocess.get | |
131 | +fineex.apiAddress=http://apicloud.fineex.net/Interface/InterfaceWeb/InterfaceFwWMS.ashx | |
132 | +fineex.method.goodsInventory=fineex.wms.product.inventory.get | |
133 | +fineex.method.orderConfirm=fineex.wms.trade.orderdetail.confirm | |
134 | +fineex.method.returnorderAdd=fineex.wms.trade.returnorder.add | |
135 | + | |
136 | + | |
137 | +qimen.api.appKey=30303007 | |
138 | +qimen.api.appSecret=80c63d1d8cf36a4c68b2df25fb93f703 | |
139 | +qimen.api.url=https://qimen.api.taobao.com/router/qmtest | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | + | |
2 | +server.port=8200 | |
3 | +server.session.timeout=10 | |
4 | +server.connection-timeout=120000 | |
5 | + | |
6 | +spring.servlet.multipart.max-file-size=10MB | |
7 | +spring.servlet.multipart.max-request-size=20MB | |
8 | + | |
9 | +spring.jackson.time-zone=GMT+8 | |
10 | +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss | |
11 | +spring.mvc.dateFormat = yyyy-MM-dd HH:mm:ss | |
12 | +spring.gson.serialize-nulls=true | |
13 | + | |
14 | +#email config | |
15 | +mail.host=smtp.taover.com | |
16 | +mail.port=25 | |
17 | +mail.username=taover-robot@taover.com | |
18 | +mail.password=Lexi@1798 | |
19 | +mail.smtp.auth=true | |
20 | +mail.smtp.sendFrom=taover-robot@taover.com | |
21 | + | |
22 | +#logback xml config | |
23 | +logging.config=classpath:logback-production.xml | |
24 | + | |
25 | +#allow http method options | |
26 | +spring.mvc.dispatch-options-request=true | |
27 | +spring.mvc.async.request-timeout=200000 | |
28 | + | |
29 | +#DB info | |
30 | +spring.datasource.url=jdbc:mysql://rdsifmezqifmezqo.mysql.rds.aliyuncs.com:3306/bzyun_wxorder_prd?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true | |
31 | +spring.datasource.username=tylife | |
32 | +spring.datasource.password=lexi365 | |
33 | +spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |
34 | +spring.datasource.max-idle=10 | |
35 | +spring.datasource.max-wait=10000 | |
36 | +spring.datasource.min-idle=5 | |
37 | +spring.datasource.initial-size=5 | |
38 | + | |
39 | +#zto analysis address url | |
40 | +zto.analysisAddress.url=https://hdgateway.zto.com/Word_AnalysisAddress | |
41 | +#taover analysis address url | |
42 | +taover.analysisAddress.url=http://address.taover.com/ | |
43 | +#kuaibao | |
44 | +kuaibao.analysisAddress.url=https://kop.kuaidihelp.com/api | |
45 | +kuaibao.analysisAddress.appId=105128 | |
46 | +kuaibao.analysisAddress.appKey=3310236ba4d6296e6e2346a7d9c824662510ff87 | |
47 | +kuaibao.analysisAddress.method=cloud.address.resolve | |
48 | +kuaibao.analysisAddress.methodSimple=cloud.address.cleanse | |
49 | + | |
50 | +#aliyun oss address | |
51 | +accessKeyId=H4fIVB56iHjR6zQw | |
52 | +accessKeySecret=7bA395UltFp16kWPJT7Pfz0XYXCk4Q | |
53 | +endpoint=oss-cn-beijing.aliyuncs.com | |
54 | +bucket_contact=8zyun-oss | |
55 | +aliyun.mnsEndpoint=http://1225610490807748.mns.cn-hangzhou.aliyuncs.com | |
56 | +#mobile message url | |
57 | +wwltData=sname=dlmzty00&spwd=A6cU4Tyx&scorpid=&sprdid=1012888 | |
58 | +wwltUrl=https://seccf.51welink.com/submitdata/service.asmx/g_Submit | |
59 | + | |
60 | +#pc api | |
61 | +pc.callcenter.url.openapiSurrogacyRegisteropenapi=https://ws.8zyun.cn:8080/v1/agent | |
62 | +pc.callcenter.url.openapiSurrogacyQuerycontacts=https://ws.8zyun.cn:8080/v1/contacts/ | |
63 | +pc.callcenter.url.openapiCallGroupMember=https://ws.8zyun.cn:8080/v1/contact/group_members/ | |
64 | +pc.callcenter.url.openapiSurrogacyAgent=https://ws.8zyun.cn:8080/v1/agent | |
65 | +pc.callcenter.url.openapiSurrogacySendmessage=https://ws.8zyun.cn:8080/v1/message_task | |
66 | +pc.callcenter.url.openapiContactsFeaturesgroup=https://ws.8zyun.cn:8080/v1/contactsMessageCount | |
67 | + | |
68 | +pc.callcenter.appid=c2MkSTjT8ghZ | |
69 | +pc.callcenter.seckey=7105ec065b8bb30fa6e3f13fccf92d0G | |
70 | +pc.callcenter.subscribeUrl=https://api.oms.8zyun.cn/api/wxagentpcmessagesubscribe | |
71 | +pc.callcenter.url.sendMessageQueueName=oms-pc-msg-production | |
72 | + | |
73 | +pc.message.url.messageTaskListUrl=https://ws.8zyun.cn:8080/v1/message_task_list | |
74 | +pc.message.url.agentMessageTask=https://ws.8zyun.cn:8080/v1/agent_message_task | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +<configuration> | |
2 | + | |
3 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
4 | + encoders are assigned the type | |
5 | + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default | |
6 | + <encoder> | |
7 | + <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
8 | + </encoder> | |
9 | + </appender> | |
10 | + | |
11 | + <root level="INFO"> | |
12 | + <appender-ref ref="STDOUT" /> | |
13 | + </root> | |
14 | +</configuration> | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +<configuration> | |
2 | + | |
3 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
4 | + <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
5 | + <encoder> | |
6 | + <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
7 | + </encoder> | |
8 | + </appender> | |
9 | + | |
10 | + <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> | |
11 | + <smtpHost>smtp.taover.com</smtpHost> | |
12 | + <smtpPort>465</smtpPort> | |
13 | + <SSL>true</SSL> | |
14 | + <username>taover-robot@taover.com</username> | |
15 | + <password>Lexi@1798</password> | |
16 | + | |
17 | + <from>taover-robot@taover.com</from> | |
18 | + <to>wangbin@taover.com</to> | |
19 | + <to>gaoming@taover.com</to> | |
20 | + <to>liuyunpeng@taover.com</to> | |
21 | + <subject>八爪云-data-analysis/ERROR:%logger{20}</subject> | |
22 | + <layout class="ch.qos.logback.classic.html.HTMLLayout"/> | |
23 | + <!-- 这里采用等级过滤器,指定等级相符才发送,这里指定ERROR级别才发送 --> | |
24 | + <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |
25 | + <level>ERROR</level> | |
26 | + <onMatch>ACCEPT</onMatch> | |
27 | + <onMismatch>DENY</onMismatch> | |
28 | + </filter> | |
29 | + <!-- 每个电子邮件只发送一个日志条目 --> | |
30 | + <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker"> | |
31 | + <bufferSize>3</bufferSize> | |
32 | + </cyclicBufferTracker> | |
33 | + </appender> | |
34 | + | |
35 | + <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
36 | + <file>logback-rolling.log</file> | |
37 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
38 | + <!-- rollover daily --> | |
39 | + <fileNamePattern>logback-roll-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
40 | + <!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB --> | |
41 | + <maxFileSize>100MB</maxFileSize> | |
42 | + <maxHistory>60</maxHistory> | |
43 | + <totalSizeCap>5GB</totalSizeCap> | |
44 | + </rollingPolicy> | |
45 | + <encoder> | |
46 | + <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg %n</pattern> | |
47 | + </encoder> | |
48 | + </appender> | |
49 | + | |
50 | + <root level="ERROR"> | |
51 | + <appender-ref ref="EMAIL"/> | |
52 | + </root> | |
53 | + | |
54 | + <root level="INFO"> | |
55 | + <appender-ref ref="ROLLING"/> | |
56 | + <appender-ref ref="STDOUT" /> | |
57 | + </root> | |
58 | + | |
59 | +</configuration> | ... | ... |