Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d4ae723a
authored
Feb 09, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
去重
1 parent
2561b87d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
218 additions
and
38 deletions
src/test/java/cn/com/glsx/test/RemoveDuplicateObjTest.java
src/test/java/cn/com/glsx/test/UtilsTest.java
src/test/java/cn/com/glsx/test/json.json
src/test/java/cn/com/glsx/test/RemoveDuplicateObjTest.java
0 → 100644
View file @
d4ae723
package
cn
.
com
.
glsx
.
test
;
import
cn.com.glsx.admin.modules.entity.ElectricFenceSns
;
import
cn.com.glsx.admin.modules.model.ElectricFenceSnsModel
;
import
cn.com.glsx.admin.modules.model.param.ElectricFenceBO
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
public
class
RemoveDuplicateObjTest
{
public
static
void
main
(
String
[]
args
)
{
String
json
=
"{\n"
+
" \"id\": 2678,\n"
+
" \"shopId\": \"612\",\n"
+
" \"fenceName\": \"A试驾路线\",\n"
+
" \"bizFenceType\": 12,\n"
+
" \"shapeType\": 3,\n"
+
" \"lnglat\": \"110.946851,21.682898|110.946089,21.68557|110.945274,21.686629|110.944727,21.687329|110.944437,21.688067|110.9433,21.688768|110.940532,21.69164|110.937335,21.694751|110.932313,21.699537|110.926348,21.706022|110.923548,21.708817|110.921971,21.712428|110.921778,21.714353|110.922357,21.716278|110.92288,21.715952|110.922802,21.712358|110.923973,21.709377|110.92626,21.706876|110.930833,21.702191|110.944287,21.689857|110.946422,21.686597|110.947827,21.683217|110.947709,21.680057|110.946969,21.680386\",\n"
+
" \"timeType\": 2,\n"
+
" \"snList\": [\n"
+
" {\n"
+
" \"sn\": \"8710315002\",\n"
+
" \"vin\": \"LHGGR988XM8000720\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710315000\",\n"
+
" \"vin\": \"LHGRU1864L8092140\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710826483\",\n"
+
" \"name\": \"黄埔工厂719\",\n"
+
" \"vin\": \"LHGFS2695N2001104\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710915694\",\n"
+
" \"name\": \"黄埔工厂1196\",\n"
+
" \"vin\": \"LHGFS1693N2002181\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710826753\",\n"
+
" \"name\": \"增城工厂449\",\n"
+
" \"vin\": \"LHGCV1687N8001341\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710915886\",\n"
+
" \"name\": \"增城工厂1038\",\n"
+
" \"vin\": \"LHGCV3680N8003640\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710625481\",\n"
+
" \"name\": \"增城工厂1383\",\n"
+
" \"vin\": \"LHGRY7889N8000385\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710922958\",\n"
+
" \"name\": \"广汽本田-型格268\",\n"
+
" \"vin\": \"LHGFE3687N2000685\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710918477\",\n"
+
" \"name\": \"广汽本田--奥德赛混动375\",\n"
+
" \"vin\": \"LHGRC4804N8000995\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710915886\",\n"
+
" \"name\": \"增城工厂1038\",\n"
+
" \"vin\": \"LHGCV3680N8003640\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710315001\",\n"
+
" \"vin\": \"LHGGS1891M8000930\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710315002\",\n"
+
" \"vin\": \"LHGGR988XM8000720\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710315000\",\n"
+
" \"vin\": \"LHGRU1864L8092140\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710826483\",\n"
+
" \"name\": \"黄埔工厂719\",\n"
+
" \"vin\": \"LHGFS2695N2001104\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710826753\",\n"
+
" \"name\": \"增城工厂449\",\n"
+
" \"vin\": \"LHGCV1687N8001341\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710915694\",\n"
+
" \"name\": \"黄埔工厂1196\",\n"
+
" \"vin\": \"LHGFS1693N2002181\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" },\n"
+
" {\n"
+
" \"sn\": \"8710915886\",\n"
+
" \"name\": \"增城工厂1038\",\n"
+
" \"vin\": \"LHGCV3680N8003640\",\n"
+
" \"userTel\": \"18988994648\"\n"
+
" }\n"
+
" ]\n"
+
"}"
;
ElectricFenceBO
fenceBO
=
JSONObject
.
parseObject
(
json
,
ElectricFenceBO
.
class
);
List
<
ElectricFenceSns
>
snsList
=
Lists
.
newArrayList
();
Date
now
=
new
Date
();
//前端目前有bug,会重复提交关联设备,换成这种方式去重 add by liuyf on 20220209
Map
<
String
,
ElectricFenceSnsModel
>
snsModelMap
=
fenceBO
.
getSnList
().
stream
()
.
collect
(
Collectors
.
toMap
(
ElectricFenceSnsModel:
:
getSn
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
//手动关联
snsModelMap
.
forEach
((
k
,
efsm
)
->
{
ElectricFenceSns
fenceSns
=
new
ElectricFenceSns
();
fenceSns
.
setSn
(
efsm
.
getSn
());
fenceSns
.
setName
(
efsm
.
getName
());
fenceSns
.
setVin
(
efsm
.
getVin
());
fenceSns
.
setUserTel
(
efsm
.
getUserTel
());
fenceSns
.
setCreatedDate
(
now
);
snsList
.
add
(
fenceSns
);
});
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
snsList
));
}
}
src/test/java/cn/com/glsx/test/UtilsTest.java
View file @
d4ae723
...
@@ -8,8 +8,10 @@ import java.util.Date;
...
@@ -8,8 +8,10 @@ import java.util.Date;
public
class
UtilsTest
{
public
class
UtilsTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Date
date
=
new
Date
();
String
filename
=
"正面"
;
System
.
out
.
println
(
"date = "
+
date
.
getHours
());
String
filepath
=
"http://qcimg01.glsx.net:7060/group1/M00/00/65/wKgD3mHRMmGACeXQAAjeFUu88pI605.jpg"
;
String
suffix
=
filepath
.
substring
(
filepath
.
lastIndexOf
(
"."
));
System
.
out
.
println
(
filename
+
suffix
);
String
lostBegin
=
DateUtil
.
formatDateYmd
(
DateUtils
.
addHours
(
new
Date
(),
-
72
));
String
lostBegin
=
DateUtil
.
formatDateYmd
(
DateUtils
.
addHours
(
new
Date
(),
-
72
));
System
.
out
.
println
(
"lostBegin = "
+
lostBegin
);
System
.
out
.
println
(
"lostBegin = "
+
lostBegin
);
...
...
src/test/java/cn/com/glsx/test/json.json
View file @
d4ae723
[
[
{
{
"locType"
:
0
,
"delFlag"
:
0
,
"onlineState"
:
1
,
"createdDate"
:
1644389492024
,
"record"
:
{
"vin"
:
"LHGGR988XM8000720"
,
"alt"
:
65
,
"sn"
:
"8710315002"
"bLat"
:
0
,
},
"bLng"
:
0
,
{
"dir"
:
133
,
"delFlag"
:
0
,
"gLat"
:
22601696
,
"createdDate"
:
1644389492024
,
"gLng"
:
113994684
,
"vin"
:
"LHGGS1891M8000930"
,
"gpsTime"
:
1621840068
,
"sn"
:
"8710315001"
"lat"
:
22604588
,
},
"lng"
:
113989712
,
{
"speed"
:
0
,
"userTel"
:
"18988994648"
,
"storeTime"
:
1621840070
"delFlag"
:
0
,
},
"createdDate"
:
1644389492024
,
"subDevType"
:
2
,
"name"
:
"黄埔工厂719"
,
"userID"
:
75105200001
"vin"
:
"LHGFS2695N2001104"
,
},
"sn"
:
"8710826483"
{
},
"locType"
:
0
,
{
"onlineState"
:
1
,
"delFlag"
:
0
,
"record"
:
{
"createdDate"
:
1644389492024
,
"alt"
:
0
,
"name"
:
"广汽本田-型格268"
,
"bLat"
:
0
,
"vin"
:
"LHGFE3687N2000685"
,
"bLng"
:
0
,
"sn"
:
"8710922958"
"dir"
:
72
,
},
"gLat"
:
22602008
,
{
"gLng"
:
113994873
,
"userTel"
:
"18988994648"
,
"gpsTime"
:
1621841500
,
"delFlag"
:
0
,
"lat"
:
22604900
,
"createdDate"
:
1644389492024
,
"lng"
:
113989900
,
"name"
:
"增城工厂449"
,
"speed"
:
0
,
"vin"
:
"LHGCV1687N8001341"
,
"storeTime"
:
1621841507
"sn"
:
"8710826753"
},
},
"subDevType"
:
2
,
{
"userID"
:
1610425254
"userTel"
:
"18988994648"
,
"delFlag"
:
0
,
"createdDate"
:
1644389492024
,
"name"
:
"广汽本田--奥德赛混动375"
,
"vin"
:
"LHGRC4804N8000995"
,
"sn"
:
"8710918477"
},
{
"userTel"
:
"18988994648"
,
"delFlag"
:
0
,
"createdDate"
:
1644389492024
,
"name"
:
"增城工厂1383"
,
"vin"
:
"LHGRY7889N8000385"
,
"sn"
:
"8710625481"
},
{
"userTel"
:
"18988994648"
,
"delFlag"
:
0
,
"createdDate"
:
1644389492024
,
"name"
:
"黄埔工厂1196"
,
"vin"
:
"LHGFS1693N2002181"
,
"sn"
:
"8710915694"
},
{
"delFlag"
:
0
,
"createdDate"
:
1644389492024
,
"vin"
:
"LHGRU1864L8092140"
,
"sn"
:
"8710315000"
},
{
"userTel"
:
"18988994648"
,
"delFlag"
:
0
,
"createdDate"
:
1644389492024
,
"name"
:
"增城工厂1038"
,
"vin"
:
"LHGCV3680N8003640"
,
"sn"
:
"8710915886"
}
}
]
]
Write
Preview
Markdown
is supported
Attach a file
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 post a comment