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
38be1e4e
Commit
38be1e4e
authored
Aug 30, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
73081c15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
AreaHelper.java
...src/main/java/com/yanzuoguang/util/helper/AreaHelper.java
+13
-3
TestAreaHelper.java
yzg-util-base/src/test/java/helper/TestAreaHelper.java
+1
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/AreaHelper.java
View file @
38be1e4e
...
...
@@ -60,7 +60,7 @@ public class AreaHelper {
String
city
=
fromAreaId
.
substring
(
3
);
String
ret
=
city
.
substring
(
0
,
length
-
3
);
String
retSimple
=
getSimple
(
ret
);
String
retSimple
=
getSimple
(
ret
,
false
);
if
(
StringHelper
.
compare
(
ret
,
retSimple
))
{
return
getFull
(
country
+
retSimple
);
}
...
...
@@ -74,11 +74,21 @@ public class AreaHelper {
* @return
*/
public
static
String
getSimple
(
String
fromAreaId
)
{
return
getSimple
(
fromAreaId
,
true
);
}
/**
* 获取简写Id
*
* @param fromAreaId
* @return
*/
public
static
String
getSimple
(
String
fromAreaId
,
boolean
isFull
)
{
if
(
StringHelper
.
isEmpty
(
fromAreaId
)
||
fromAreaId
.
length
()
<=
3
)
{
return
fromAreaId
;
}
String
to
=
StringHelper
.
trimEnd
(
fromAreaId
,
"00"
);
if
(
to
.
length
()
<
COUNTRY_LENGTH
)
{
if
(
to
.
length
()
<
COUNTRY_LENGTH
&&
isFull
)
{
to
=
getFull
(
to
).
substring
(
0
,
COUNTRY_LENGTH
);
}
return
to
;
...
...
@@ -115,7 +125,7 @@ public class AreaHelper {
if
(
StringHelper
.
isEmpty
(
fromAreaId
))
{
return
fromAreaId
;
}
String
simpleId
=
getSimple
(
fromAreaId
);
String
simpleId
=
getSimple
(
fromAreaId
,
true
);
String
parentSimpleId
=
StringHelper
.
EMPTY
;
if
(
simpleId
.
length
()
>
COUNTRY_LENGTH
)
{
parentSimpleId
=
simpleId
.
substring
(
0
,
simpleId
.
length
()
-
2
);
...
...
yzg-util-base/src/test/java/helper/TestAreaHelper.java
View file @
38be1e4e
...
...
@@ -8,6 +8,7 @@ public class TestAreaHelper {
public
void
test
()
{
System
.
out
.
println
(
AreaHelper
.
getSimple
(
"100000000"
));
System
.
out
.
println
(
AreaHelper
.
getFull
(
"100"
));
System
.
out
.
println
(
AreaHelper
.
getAreaId
(
"100000000"
));
String
from
=
"100500103"
;
// from = 1999;
...
...
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