Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
41da4c45
Commit
41da4c45
authored
Jun 28, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL层级处理的支持
parent
57a898c8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
455 additions
and
0 deletions
+455
-0
pom.xml
pom.xml
+7
-0
pom.xml
yzg-util-chinese/pom.xml
+47
-0
readme.md
yzg-util-chinese/src/main/java/com/yanzuoguang/readme.md
+0
-0
readme.txt
yzg-util-chinese/src/main/java/com/yanzuoguang/readme.txt
+0
-0
ChineseHelper.java
...ese/src/main/java/com/yanzuoguang/util/ChineseHelper.java
+56
-0
HanziVo.java
...l-chinese/src/main/java/com/yanzuoguang/util/HanziVo.java
+32
-0
TestChineseHelper.java
yzg-util-chinese/src/test/java/helper/TestChineseHelper.java
+18
-0
from.json
yzg-util-chinese/src/test/java/helper/from.json
+141
-0
from_xx.json
yzg-util-chinese/src/test/java/helper/from_xx.json
+154
-0
No files found.
pom.xml
View file @
41da4c45
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
<module>
yzg-util-mq
</module>
<module>
yzg-util-mq
</module>
<module>
yzg-util-image
</module>
<module>
yzg-util-image
</module>
<module>
yzg-util-print
</module>
<module>
yzg-util-print
</module>
<module>
yzg-util-chinese
</module>
</modules>
</modules>
<properties>
<properties>
...
@@ -147,6 +148,12 @@
...
@@ -147,6 +148,12 @@
<artifactId>
yzg-util-print
</artifactId>
<artifactId>
yzg-util-print
</artifactId>
<version>
${yzg.version}
</version>
<version>
${yzg.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.yanzuoguang
</groupId>
<artifactId>
yzg-util-chinese
</artifactId>
<version>
${yzg.version}
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
yzg-util-chinese/pom.xml
0 → 100755
View file @
41da4c45
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
yzg-util
</artifactId>
<groupId>
com.yanzuoguang
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
yzg-util-chinese
</artifactId>
<properties>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<baidu.aip>
4.12.0
</baidu.aip>
</properties>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
<dependency>
<groupId>
com.yanzuoguang
</groupId>
<artifactId>
yzg-util-base
</artifactId>
</dependency>
<dependency>
<groupId>
com.belerweb
</groupId>
<artifactId>
pinyin4j
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
com.baidu.aip
</groupId>
<artifactId>
java-sdk
</artifactId>
<version>
${baidu.aip}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
yzg-util-chinese/src/main/java/com/yanzuoguang/readme.md
0 → 100644
View file @
41da4c45
yzg-util-chinese/src/main/java/com/yanzuoguang/readme.txt
0 → 100644
View file @
41da4c45
yzg-util-chinese/src/main/java/com/yanzuoguang/util/ChineseHelper.java
0 → 100644
View file @
41da4c45
package
com
.
yanzuoguang
.
util
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
net.sourceforge.pinyin4j.PinyinHelper
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinToneType
;
import
java.util.*
;
import
java.util.regex.Pattern
;
/**
* 构造函数
* <p>
* 百度语音合成接口文档: https://ai.baidu.com/ai-doc/SPEECH/sk38y8hb7
*
* @author 颜佐光
*/
public
class
ChineseHelper
{
/***
* ^[\u2E80-\u9FFF]+$ 匹配所有东亚区的语言
* ^[\u4E00-\u9FFF]+$ 匹配简体和繁体
* ^[\u4E00-\u9FA5]+$ 匹配简体
*/
private
static
Pattern
pattern
=
Pattern
.
compile
(
"^[\u4E00-\u9FFF]+$"
);
/**
* 获取汉字全拼
*
* @param from 来源汉字
* @return
*/
public
static
List
<
HanziVo
>
get
(
String
from
)
{
if
(
StringHelper
.
isEmpty
(
from
))
{
return
new
ArrayList
<>(
0
);
}
List
<
HanziVo
>
rets
=
new
ArrayList
<>(
from
.
length
()
/
2
);
for
(
int
i
=
0
;
i
<
from
.
length
();
i
++)
{
char
unit
=
from
.
charAt
(
i
);
HanziVo
hanzi
=
new
HanziVo
();
hanzi
.
setFrom
(
unit
);
// 是汉字,则转拼音
if
(
pattern
.
matcher
(
String
.
valueOf
(
unit
)).
find
())
{
try
{
String
[]
items
=
PinyinHelper
.
toHanyuPinyinStringArray
(
unit
);
hanzi
.
setTos
(
items
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
rets
.
add
(
hanzi
);
}
return
rets
;
}
}
yzg-util-chinese/src/main/java/com/yanzuoguang/util/HanziVo.java
0 → 100644
View file @
41da4c45
package
com
.
yanzuoguang
.
util
;
/**
* 汉字处理
*/
public
class
HanziVo
{
/**
* 来源汉字
*/
private
char
from
;
/**
* 目标拼音
*/
private
String
[]
tos
;
public
char
getFrom
()
{
return
from
;
}
public
void
setFrom
(
char
from
)
{
this
.
from
=
from
;
}
public
String
[]
getTos
()
{
return
tos
;
}
public
void
setTos
(
String
[]
tos
)
{
this
.
tos
=
tos
;
}
}
yzg-util-chinese/src/test/java/helper/TestChineseHelper.java
0 → 100644
View file @
41da4c45
package
helper
;
import
com.yanzuoguang.util.ChineseHelper
;
import
com.yanzuoguang.util.HanziVo
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
org.junit.Test
;
import
java.util.List
;
public
class
TestChineseHelper
{
@Test
public
void
testConvert
()
{
String
text
=
"颜佐光喜欢游泳"
;
List
<
HanziVo
>
items
=
ChineseHelper
.
get
(
text
);
System
.
out
.
println
(
"json:"
+
JsonHelper
.
serialize
(
items
,
true
));
}
}
yzg-util-chinese/src/test/java/helper/from.json
0 → 100644
View file @
41da4c45
{
"PageWidth"
:
73
,
"PageHeight"
:
50
,
"MarginTop"
:
125
,
"MarginRight"
:
0
,
"MarginBottom"
:
0
,
"MarginLeft"
:
0
,
"PrintAngle"
:
0
,
"Items"
:
[
{
"Name"
:
"OrderId"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
4.266013763896241
,
"Left"
:
25.329221810481734
,
"Width"
:
39.926945473795655
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"订单编号:{0}"
,
"FormatValue"
:
"订单编号:"
},
{
"Name"
:
"createDate"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
14.942985706723134
,
"Left"
:
25.34970884065643
,
"Width"
:
46.9081524616199
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"出票时间:{0}"
,
"FormatValue"
:
"出票时间:2019-10-16 16:11:01"
},
{
"Name"
:
"codeNo"
,
"Type"
:
2
,
"IsVisible"
:
true
,
"Top"
:
4.51799894123875
,
"Left"
:
5.020275277924827
,
"Width"
:
18.073398623610373
,
"Height"
:
18.073398623610373
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
""
,
"FormatValue"
:
"01234567890123"
},
{
"Name"
:
"codeNo"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
9.331815775542616
,
"Left"
:
25.329221810481734
,
"Width"
:
40.72922181048174
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"电子券号:{0}"
,
"FormatValue"
:
"电子券号:01234567890123"
},
{
"Name"
:
"channelName"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
29.861302276336687
,
"Left"
:
5.065802011646373
,
"Width"
:
43.971678136580195
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"渠道来源:{0}"
,
"FormatValue"
:
"渠道来源:窗口"
},
{
"Name"
:
"buyNum"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
34.676283748014825
,
"Left"
:
5.067840127051349
,
"Width"
:
33.0574377977766
,
"Height"
:
5.558496559025939
,
"Font"
:
"微软雅黑,12pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"可用人数:{0}"
,
"FormatValue"
:
"可用人数:1"
},
{
"Name"
:
"Common"
,
"Type"
:
0
,
"IsVisible"
:
true
,
"Top"
:
40.497617787188986
,
"Left"
:
5.012122816304924
,
"Width"
:
65.82530439385918
,
"Height"
:
8.99947061937533
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"索道门票限当日22:00前使用,巴士门票限当日19:00前使用,一经售出不可退换(北站售)"
,
"FormatValue"
:
"索道门票限当日22:00前使用,巴士门票限当日19:00前使用,一经售出不可退换(北站售)"
},
{
"Name"
:
"productName"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
24.795976707252514
,
"Left"
:
5.065802011646373
,
"Width"
:
46.883271572260455
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"客票类别:{0:*:2,2,1}"
,
"FormatValue"
:
"客票类别:途比达门票(自动修改)"
},
{
"Name"
:
"PlayerType"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
19.730121757543674
,
"Left"
:
25.329221810481734
,
"Width"
:
26.35322922181048
,
"Height"
:
4.235044997353096
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"游客类型:{0}"
,
"FormatValue"
:
"游客类型:"
},
{
"Name"
:
"salePriceTotal"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
34.66225516146109
,
"Left"
:
39.194547379565904
,
"Width"
:
29.2649550026469
,
"Height"
:
5.558496559025939
,
"Font"
:
"微软雅黑,12pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"票价:{0}"
,
"FormatValue"
:
"票价:20"
}
]
}
\ No newline at end of file
yzg-util-chinese/src/test/java/helper/from_xx.json
0 → 100644
View file @
41da4c45
{
"PageWidth"
:
73
,
"PageHeight"
:
50
,
"MarginTop"
:
125
,
"MarginRight"
:
0
,
"MarginBottom"
:
0
,
"MarginLeft"
:
0
,
"PrintAngle"
:
0
,
"Items"
:
[
{
"Name"
:
"codeNo"
,
"Type"
:
2
,
"IsVisible"
:
true
,
"Top"
:
1.9355849655902593
,
"Left"
:
2.399322392800424
,
"Width"
:
20.219031233456857
,
"Height"
:
20.219031233456857
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"01234567890123"
,
"FormatValue"
:
"01234567890123"
},
{
"Name"
:
"codeNo"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
6.087877183695076
,
"Left"
:
24.086818422445738
,
"Width"
:
46.18845950238221
,
"Height"
:
4.499735309687665
,
"Font"
:
"微软雅黑,9pt,style=Bold,Italic,Underline,"
,
"TextAlign"
:
1
,
"Format"
:
"电子券号:{0}"
,
"FormatValue"
:
"电子券号:01234567890123"
},
{
"Name"
:
"createDate"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
11.463102170460562
,
"Left"
:
24.29563260984648
,
"Width"
:
46.99920592906299
,
"Height"
:
5.2938062466913705
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"出票时间:{0}"
,
"FormatValue"
:
"出票时间:2019-10-16 16:11:01"
},
{
"Name"
:
"productName"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
1.0073028057173108
,
"Left"
:
24.29563260984648
,
"Width"
:
42.54896770778189
,
"Height"
:
4.238353626257279
,
"Font"
:
"微软雅黑,9pt,style=Bold"
,
"TextAlign"
:
1
,
"Format"
:
"客票类别:{0}"
,
"FormatValue"
:
"客票类别:途比达门票(自动修改)"
},
{
"Name"
:
"channelName"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
17.1644785600847
,
"Left"
:
24.37673372154579
,
"Width"
:
44.35230280571731
,
"Height"
:
4.499735309687665
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"旅行社:{0}"
,
"FormatValue"
:
"旅行社:窗口"
},
{
"Name"
:
"buyNum"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
22.768501852832188
,
"Left"
:
24.37673372154579
,
"Width"
:
16.979883536262573
,
"Height"
:
4.238353626257279
,
"Font"
:
"微软雅黑,9pt,style=Bold"
,
"TextAlign"
:
1
,
"Format"
:
"人数:{0}"
,
"FormatValue"
:
"人数:1"
},
{
"Name"
:
"Common"
,
"Type"
:
0
,
"IsVisible"
:
true
,
"Top"
:
32.66278454208576
,
"Left"
:
2.794547379565908
,
"Width"
:
68.45897300158813
,
"Height"
:
8.476707252514558
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"门票限当日 22:00 前使用,一经售出不可退换(南站票)"
,
"FormatValue"
:
"门票限当日 22:00 前使用,一经售出不可退换(南站票)"
},
{
"Name"
:
"visitorCardId"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
27.665696135521436
,
"Left"
:
27.99655902593965
,
"Width"
:
34.66119640021175
,
"Height"
:
4.238353626257279
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
" "
,
"FormatValue"
:
" "
},
{
"Name"
:
"sortNo"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
42.024351508734775
,
"Left"
:
2.4116728427739544
,
"Width"
:
25.671651667548968
,
"Height"
:
5.558496559025939
,
"Font"
:
"微软雅黑,12pt,style=Bold"
,
"TextAlign"
:
1
,
"Format"
:
"排号:{0}"
,
"FormatValue"
:
"排号:2"
},
{
"Name"
:
"sortNoTime"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
42.0857596611964
,
"Left"
:
27.561143462149285
,
"Width"
:
145.51032292218105
,
"Height"
:
5.823186871360509
,
"Font"
:
"微软雅黑,9pt,style=Bold"
,
"TextAlign"
:
1
,
"Format"
:
"预计排队进入时间:{0}"
,
"FormatValue"
:
"预计排队进入时间:12:55"
},
{
"Name"
:
"visitorName"
,
"Type"
:
1
,
"IsVisible"
:
true
,
"Top"
:
27.795659078877712
,
"Left"
:
2.4175304393859185
,
"Width"
:
24.477236633139224
,
"Height"
:
4.800820539968237
,
"Font"
:
"微软雅黑,9pt,style=Underline"
,
"TextAlign"
:
1
,
"Format"
:
"导游:{0}"
,
"FormatValue"
:
"导游:颜佐光"
}
]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment