Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
9ab3ed77
Commit
9ab3ed77
authored
Jun 27, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改违章,把查询到的车型代码和类型保存到数据库
parent
e62b0829
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
221 additions
and
34 deletions
+221
-34
LicensePlateType.java
.../com/xxfc/platform/universal/entity/LicensePlateType.java
+60
-0
SearchableCity.java
...va/com/xxfc/platform/universal/entity/SearchableCity.java
+1
-1
LicensePlateTypeBiz.java
.../com/xxfc/platform/universal/biz/LicensePlateTypeBiz.java
+17
-0
SearchableCityBiz.java
...va/com/xxfc/platform/universal/biz/SearchableCityBiz.java
+15
-0
LicensePlateTypeMapper.java
...xfc/platform/universal/mapper/LicensePlateTypeMapper.java
+11
-0
SearchableCityMapper.java
.../xxfc/platform/universal/mapper/SearchableCityMapper.java
+12
-0
TrafficViolationsService.java
.../platform/universal/service/TrafficViolationsService.java
+54
-33
LicensePlateType.xml
...cle-server/src/main/resources/mapper/LicensePlateType.xml
+10
-0
SearchableCityMapper.xml
...server/src/main/resources/mapper/SearchableCityMapper.xml
+6
-0
TimeTest.java
...ver/src/test/java/com/xxfc/platform/vehicle/TimeTest.java
+35
-0
No files found.
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/LicensePlateType.java
0 → 100644
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
tk.mybatis.mapper.annotation.KeySql
;
import
tk.mybatis.mapper.code.IdentityDialect
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
public
class
LicensePlateType
implements
Serializable
{
/**
* id
*/
@Id
@KeySql
(
dialect
=
IdentityDialect
.
MYSQL
)
private
Integer
id
;
/**
* 车型代码
*/
private
String
code
;
/**
* 车型类型
*/
private
String
type
;
/**
* 创建时间
*/
@Column
(
name
=
"create_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT-8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createDate
;
/**
* 修改时间
*/
@Column
(
name
=
"update_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT-8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateDate
;
public
LicensePlateType
(
String
code
,
String
type
,
Date
createDate
)
{
this
.
code
=
code
;
this
.
type
=
type
;
this
.
createDate
=
createDate
;
}
public
LicensePlateType
()
{
}
}
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/
s
earchableCity.java
→
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/
S
earchableCity.java
View file @
9ab3ed77
...
...
@@ -11,7 +11,7 @@ import javax.persistence.Id;
import
java.util.Date
;
@Data
public
class
s
earchableCity
{
public
class
S
earchableCity
{
@Id
@KeySql
(
dialect
=
IdentityDialect
.
MYSQL
)
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/LicensePlateTypeBiz.java
0 → 100644
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.xxfc.platform.universal.entity.LicensePlateType
;
import
com.xxfc.platform.universal.entity.SearchableCity
;
import
com.xxfc.platform.universal.mapper.LicensePlateTypeMapper
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
@Service
public
class
LicensePlateTypeBiz
extends
BaseBiz
<
LicensePlateTypeMapper
,
LicensePlateType
>
{
public
void
insertLicensePlateType
(
ArrayList
<
LicensePlateType
>
licensePlateTypes
)
{
mapper
.
insertLicensePlateType
(
licensePlateTypes
);
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/SearchableCityBiz.java
0 → 100644
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
biz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.xxfc.platform.universal.entity.SearchableCity
;
import
com.xxfc.platform.universal.mapper.SearchableCityMapper
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
@Service
public
class
SearchableCityBiz
extends
BaseBiz
<
SearchableCityMapper
,
SearchableCity
>
{
public
void
insertSearchableCities
(
ArrayList
<
SearchableCity
>
searchableCities
)
{
mapper
.
insertSearchableCities
(
searchableCities
);
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/mapper/LicensePlateTypeMapper.java
0 → 100644
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
mapper
;
import
com.xxfc.platform.universal.entity.LicensePlateType
;
import
org.apache.ibatis.annotations.Param
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.ArrayList
;
public
interface
LicensePlateTypeMapper
extends
Mapper
<
LicensePlateType
>
{
void
insertLicensePlateType
(
@Param
(
"licensePlateTypes"
)
ArrayList
<
LicensePlateType
>
licensePlateTypes
);
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/mapper/SearchableCityMapper.java
0 → 100644
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
mapper
;
import
com.xxfc.platform.universal.entity.SearchableCity
;
import
org.apache.ibatis.annotations.Param
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.ArrayList
;
public
interface
SearchableCityMapper
extends
Mapper
<
SearchableCity
>
{
void
insertSearchableCities
(
@Param
(
value
=
"searchableCities"
)
ArrayList
<
SearchableCity
>
searchableCities
);
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/TrafficViolationsService.java
View file @
9ab3ed77
package
com
.
xxfc
.
platform
.
universal
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xxfc.platform.universal.entity.searchableCity
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.xxfc.platform.universal.biz.LicensePlateTypeBiz
;
import
com.xxfc.platform.universal.biz.SearchableCityBiz
;
import
com.xxfc.platform.universal.entity.LicensePlateType
;
import
com.xxfc.platform.universal.utils.CertifHttpUtils
;
import
com.xxfc.platform.universal.vo.TrafficViolations
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Schedules
;
import
org.springframework.stereotype.Service
;
import
java.io.UnsupportedEncodingException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -25,6 +26,9 @@ import java.util.regex.Pattern;
@Service
public
class
TrafficViolationsService
{
@Autowired
private
LicensePlateTypeBiz
licensePlateTypeBiz
;
@Value
(
"${ALIYUN.CODE}"
)
private
String
CODE
;
@Value
(
"${RETURN.TYPE}"
)
...
...
@@ -50,29 +54,29 @@ public class TrafficViolationsService {
/**
* 支持城市
*
* 支持查询的城市
* @return
* @throws Exception
type 返回参数类型
* @throws Exception
*/
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
// @Scheduled(cron = "0 0 0 * * ?")
public
String
getCity
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
querys
.
put
(
TYPE_NAME
,
TYPE
);
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
CITY_HOST
,
CITY_PATH
,
CITY_METHOD
,
headers
,
querys
);
HttpEntity
entity
=
httpResponse
.
getEntity
();
String
result
=
EntityUtils
.
toString
(
entity
);
JSONObject
.
parseObject
(
result
,
searchableCity
.
class
);
// String result = EntityUtils.toString(entity);
// ArrayList<SearchableCity> searchableCities = JSONObject.parseObject(result, ArrayList.class);
// searchableCities.forEach(searchableCity ->searchableCity.setCreateDate(new Date()) );
// searchableCityBiz.insertSearchableCities(searchableCities);
return
unicodeToString
(
EntityUtils
.
toString
(
entity
));
}
/**
/**
s
* 违章车辆查询
*
* @param trafficViolations
* @return
*/
...
...
@@ -97,25 +101,26 @@ public class TrafficViolationsService {
*
*/
public
String
getLicensePlateType
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
HashMap
<
String
,
String
>
querys
=
new
HashMap
<>();
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
GET_LICENSE_PLATE_TYPE_HOST
,
GET_LICENSE_PLATE_TYPE_PATH
,
GET_LICENSE_PLATE_TYPE_METHOD
,
headers
,
querys
);
HttpEntity
entity
=
httpResponse
.
getEntity
();
public
void
getLicensePlateType
()
throws
Exception
{
String
result
=
searchaLicensePlateType
();
return
unicodeToString
(
EntityUtils
.
toString
(
entity
));
if
(
StringUtils
.
isBlank
(
result
))
{
throw
new
BaseException
(
"错误! 查询不到车辆类型"
);
}
Map
<
String
,
Object
>
resultMap
=
JSONObject
.
parseObject
(
result
,
Map
.
class
);
Integer
status
=
(
Integer
)
resultMap
.
get
(
"status"
);
Map
<
String
,
String
>
licensePlateTypeMap
=
(
Map
<
String
,
String
>)
resultMap
.
get
(
"result"
);
if
(
status
!=
200
||
licensePlateTypeMap
==
null
)
{
throw
new
BaseException
(
"错误! 查询不到车辆类型"
);
}
ArrayList
<
LicensePlateType
>
licensePlateTypes
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
String
>
licensePlateTypeEntry
:
licensePlateTypeMap
.
entrySet
())
{
licensePlateTypes
.
add
(
new
LicensePlateType
(
licensePlateTypeEntry
.
getKey
(),
licensePlateTypeEntry
.
getValue
(),
new
Date
()));
}
licensePlateTypeBiz
.
insertLicensePlateType
(
licensePlateTypes
);
}
/**
* Unicode转汉字字符串
* @param str
...
...
@@ -141,7 +146,23 @@ public class TrafficViolationsService {
}
/**
* 调用接口获取车辆车型和代码
* @return
* @throws Exception
*/
public
String
searchaLicensePlateType
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
HashMap
<
String
,
String
>
querys
=
new
HashMap
<>();
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
GET_LICENSE_PLATE_TYPE_HOST
,
GET_LICENSE_PLATE_TYPE_PATH
,
GET_LICENSE_PLATE_TYPE_METHOD
,
headers
,
querys
);
HttpEntity
entity
=
httpResponse
.
getEntity
();
return
unicodeToString
(
EntityUtils
.
toString
(
entity
));
}
}
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/LicensePlateType.xml
0 → 100644
View file @
9ab3ed77
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxfc.platform.universal.mapper.LicensePlateTypeMapper"
>
<insert
id=
"insertLicensePlateType"
parameterType=
"List"
>
insert into license_plate_type (code,type,create_date,update_date) values
<foreach
collection=
"licensePlateTypes"
item=
"lpt"
index=
"index"
separator=
","
>
(#{lpt.code},#{lpt.createDate},#{lpt.updateDate})
</foreach>
</insert>
</mapper>
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/SearchableCityMapper.xml
0 → 100644
View file @
9ab3ed77
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxfc.platform.universal.mapper.SearchableCityMapper"
>
<insert
id=
"insertSearchableCities"
parameterType=
"List"
>
</insert>
</mapper>
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/test/java/com/xxfc/platform/vehicle/TimeTest.java
View file @
9ab3ed77
...
...
@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -31,4 +32,38 @@ public class TimeTest {
DateTime
startDay
=
DateTime
.
parse
(
"2019-06-04"
,
DEFAULT_DATE_TIME_FORMATTER
);
System
.
out
.
println
(
"test"
);
}
@Test
public
void
testStream
()
throws
Exception
{
ArrayList
<
Student
>
students
=
new
ArrayList
<>();
students
.
add
(
new
Student
(
"张1"
,
"11"
));
students
.
add
(
new
Student
(
"张2"
,
"12"
));
students
.
add
(
new
Student
(
"张3"
,
"13"
));
students
.
add
(
new
Student
(
"张4"
,
"14"
));
students
.
add
(
new
Student
(
"张5"
,
"15"
));
int
i
=
0
;
students
.
forEach
(
student
->
student
.
setCode
(
1
));
students
.
forEach
(
System
.
out
::
println
);
}
}
@Data
class
Student
implements
Serializable
{
private
String
name
;
private
String
age
;
private
int
code
;
public
Student
(
String
name
,
String
age
,
int
code
)
{
this
.
name
=
name
;
this
.
age
=
age
;
this
.
code
=
code
;
}
public
Student
(
String
name
,
String
age
)
{
this
.
name
=
name
;
this
.
age
=
age
;
}
}
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