Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
Project
Project
Details
Activity
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
WitCloud
TDLCloud
Commits
34c42b90
Commit
34c42b90
authored
May 25, 2018
by
chenying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.25添加车辆管理
parent
b9970fef
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
480 additions
and
2 deletions
+480
-2
ResultCarVo.java
src/main/java/com/example/tdl/domain/vo/ResultCarVo.java
+53
-0
UpdateCarVo.java
src/main/java/com/example/tdl/domain/vo/UpdateCarVo.java
+44
-0
Car.java
src/main/java/com/example/tdl/entity/Car.java
+53
-0
CarMapper.java
src/main/java/com/example/tdl/mapper/CarMapper.java
+24
-0
CarService.java
src/main/java/com/example/tdl/service/CarService.java
+43
-0
CarController.java
src/main/java/com/example/tdl/web/CarController.java
+197
-0
application.properties
src/main/resources/application.properties
+2
-2
messages_zh_CN.properties
src/main/resources/i18n/messages_zh_CN.properties
+10
-0
CarMapper.xml
src/main/resources/mapper/CarMapper.xml
+53
-0
mybatis-config.xml
src/main/resources/mybatis-config.xml
+1
-0
No files found.
src/main/java/com/example/tdl/domain/vo/ResultCarVo.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
ResultCarVo
{
private
String
carNo
;
private
String
type
;
private
String
img
;
private
String
companyName
;
private
String
remark
;
public
String
getCarNo
()
{
return
carNo
;
}
public
void
setCarNo
(
String
carNo
)
{
this
.
carNo
=
carNo
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getImg
()
{
return
img
;
}
public
void
setImg
(
String
img
)
{
this
.
img
=
img
;
}
public
String
getCompanyName
()
{
return
companyName
;
}
public
void
setCompanyName
(
String
companyName
)
{
this
.
companyName
=
companyName
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
}
src/main/java/com/example/tdl/domain/vo/UpdateCarVo.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
UpdateCarVo
{
private
String
carNo
;
private
String
type
;
private
String
img
;
private
String
remark
;
public
String
getCarNo
()
{
return
carNo
;
}
public
void
setCarNo
(
String
carNo
)
{
this
.
carNo
=
carNo
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getImg
()
{
return
img
;
}
public
void
setImg
(
String
img
)
{
this
.
img
=
img
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
}
src/main/java/com/example/tdl/entity/Car.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
entity
;
public
class
Car
{
private
Integer
id
;
private
String
carNo
;
private
String
type
;
private
String
img
;
private
String
remark
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getCarNo
()
{
return
carNo
;
}
public
void
setCarNo
(
String
carNo
)
{
this
.
carNo
=
carNo
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getImg
()
{
return
img
;
}
public
void
setImg
(
String
img
)
{
this
.
img
=
img
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
}
src/main/java/com/example/tdl/mapper/CarMapper.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
mapper
;
import
com.example.tdl.domain.vo.*
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
CarMapper
{
List
<
ResultCarVo
>
getAll
(
String
companyName
);
ResultCarVo
getByCarNo
(
@Param
(
"companyName"
)
String
companyName
,
@Param
(
"carNo"
)
String
carNo
);
List
<
ResultCarVo
>
getByCarNoForLike
(
@Param
(
"companyName"
)
String
companyName
,
@Param
(
"carNo"
)
String
carNo
);
int
addCar
(
ResultCarVo
resultCarVo
);
int
updateCar
(
UpdateCarVo
updateAlarmVo
);
int
delCar
(
String
carNo
);
}
src/main/java/com/example/tdl/service/CarService.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.mapper.AlarmMapper
;
import
com.example.tdl.mapper.CarMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
CarService
{
@Autowired
private
CarMapper
carMapper
;
public
List
<
ResultCarVo
>
getAll
(
String
companyName
){
return
carMapper
.
getAll
(
companyName
);
}
public
ResultCarVo
getByCarNo
(
String
companyName
,
String
carNo
){
return
carMapper
.
getByCarNo
(
companyName
,
carNo
);
}
public
List
<
ResultCarVo
>
getByCarNoForLike
(
String
companyName
,
String
carNo
){
return
carMapper
.
getByCarNoForLike
(
companyName
,
carNo
);
}
public
int
addCar
(
ResultCarVo
resultCarVo
){
return
carMapper
.
addCar
(
resultCarVo
);
}
public
int
updateCar
(
UpdateCarVo
updateCarVo
){
return
carMapper
.
updateCar
(
updateCarVo
);
}
public
int
delCar
(
String
carNo
){
return
carMapper
.
delCar
(
carNo
);
}
}
src/main/java/com/example/tdl/web/CarController.java
0 → 100644
View file @
34c42b90
package
com
.
example
.
tdl
.
web
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.service.AlarmService
;
import
com.example.tdl.service.CarService
;
import
com.example.tdl.service.TDLLogService
;
import
com.example.tdl.service.WarehouseService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
@RequestMapping
(
"/car"
)
public
class
CarController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
CarController
.
class
);
CommFeedback
fb
=
new
CommFeedback
();
Gson
gson
=
new
Gson
();
@Autowired
private
CarService
carService
=
new
CarService
();
@Autowired
private
TokenRedisService
tokenRedisService
;
@Autowired
private
I18nController
i18n
;
//查询该公司的车辆信息
@ApiOperation
(
value
=
"查询该公司的车辆信息"
,
notes
=
"查询该公司的车辆信息,返回值说明:"
+
" carNo:车牌号,"
+
" type:车辆类型,"
+
" img:车辆图片地址,"
+
" remark:备注"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
false
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/getAll"
,
method
=
RequestMethod
.
GET
)
public
Object
getAll
(
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
return
carService
.
getAll
(
user
.
getCompanyName
());
}
//根据车牌号模糊查询
@ApiOperation
(
value
=
"根据车牌号模糊查询"
,
notes
=
"根据车牌号模糊查询,返回值说明:"
+
" carNo:车牌号,"
+
" type:车辆类型,"
+
" img:车辆图片地址,"
+
" remark:备注"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
false
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/getByCarNoForLike"
,
method
=
RequestMethod
.
POST
)
public
Object
getByCarNoForLike
(
@RequestBody
String
carNo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
carNo
);
carNo
=(
String
)
jsonObject
.
get
(
"carNo"
);
return
carService
.
getByCarNoForLike
(
user
.
getCompanyName
(),
carNo
);
}
//添加车辆信息
@ApiOperation
(
value
=
"添加车辆信息"
,
notes
=
"添加车辆信息,companyName不用传,需要传递参数:"
+
" carNo:车牌号,"
+
" type:车辆类型,"
+
" img:车辆图片地址,"
+
" remark:备注"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
false
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/addCar"
,
method
=
RequestMethod
.
POST
)
public
Object
addCar
(
@RequestBody
ResultCarVo
resultCarVo
,
HttpServletRequest
request
){
String
port
=
request
.
getHeader
(
"AccountLanguage"
);
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
if
(
StringUtils
.
isEmpty
(
resultCarVo
.
getCarNo
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"carNo"
));
return
gson
.
toJson
(
fb
);
}
if
(
StringUtils
.
isEmpty
(
resultCarVo
.
getType
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"type"
));
return
gson
.
toJson
(
fb
);
}
if
(
carService
.
getByCarNo
(
user
.
getCompanyName
(),
resultCarVo
.
getCarNo
())!=
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"repetitionCarNo"
));
return
gson
.
toJson
(
fb
);
}
resultCarVo
.
setCompanyName
(
user
.
getCompanyName
());
int
a
=
carService
.
addCar
(
resultCarVo
);
if
(
a
>
0
){
fb
.
setCode
(
1
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"addCarSuccess"
));
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"addCarFailure"
));
}
return
gson
.
toJson
(
fb
);
}
//修改车辆信息
@ApiOperation
(
value
=
"修改车辆信息"
,
notes
=
"修改车辆信息,companyName不用传,需要传递参数:"
+
" oldCarNo:需要修改的预警类型,"
+
" carNo:车牌号,"
+
" type:车辆类型,"
+
" img:车辆图片地址,"
+
" remark:备注"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
false
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/updateCar"
,
method
=
RequestMethod
.
POST
)
public
Object
updateCar
(
@RequestBody
UpdateCarVo
updateCarVo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
String
port
=
request
.
getHeader
(
"AccountLanguage"
);
if
(
StringUtils
.
isEmpty
(
updateCarVo
.
getCarNo
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"carNo"
));
return
gson
.
toJson
(
fb
);
}
if
(
StringUtils
.
isEmpty
(
updateCarVo
.
getType
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"type"
));
return
gson
.
toJson
(
fb
);
}
int
a
=
carService
.
updateCar
(
updateCarVo
);
if
(
a
>
0
){
fb
.
setCode
(
1
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"updateCarSuccess"
));
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"updateCarFailure"
));
}
return
gson
.
toJson
(
fb
);
}
//删除车辆信息
@ApiOperation
(
value
=
"删除车辆信息"
,
notes
=
"删除车辆信息,carNo:需要删除的车牌号"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
false
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/delCar"
,
method
=
RequestMethod
.
POST
)
public
Object
delCar
(
@RequestBody
String
carNo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
String
port
=
request
.
getHeader
(
"AccountLanguage"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
carNo
);
carNo
=(
String
)
jsonObject
.
get
(
"carNo"
);
if
(
StringUtils
.
isEmpty
(
carNo
)){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"车牌号不能为空"
));
return
gson
.
toJson
(
fb
);
}
int
a
=
carService
.
delCar
(
carNo
);
if
(
a
>
0
){
fb
.
setCode
(
1
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"deleteCarSuccess"
));
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"deleteCarFailure"
));
}
return
gson
.
toJson
(
fb
);
}
}
src/main/resources/application.properties
View file @
34c42b90
spring.datasource.url
=
jdbc:mysql://192.168.1.
16
:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url
=
jdbc:mysql://192.168.1.
53
:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username
=
root
spring.datasource.password
=
37774020
spring.datasource.password
=
root
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
...
...
src/main/resources/i18n/messages_zh_CN.properties
View file @
34c42b90
...
...
@@ -179,3 +179,13 @@ deleteRegionSuccess=\u5220\u9664\u533A\u57DF\u6210\u529F
deleteRegionFailure
=
\u5220\u9664\u
533A
\u
57DF
\u5931\u
8D25
repetitionRegionName
=
\u
533A
\u
57DF
\u
540D
\u
91CD
\u
590D
useingRegion
=
\u
533A
\u
57DF
\u
6B63
\u5728\u
4F7F
\u7528\u
4E2D
#\u8F66\u8F86
carNo
=
\u
8F66
\u
724C
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
type
=
\u
8F66
\u
578B
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
repetitionCarNo
=
\u
8F66
\u
724C
\u
53F7
\u
91CD
\u
590D
addCarSuccess
=
\u
8F66
\u
8F86
\u
6DFB
\u
52A0
\u6210\u
529F
addCarFailure
=
\u
8F66
\u
8F86
\u
6DFB
\u
52A0
\u5931\u
8D25
updateCarSuccess
=
\u
8F66
\u
8F86
\u
4FEE
\u6539\u6210\u
529F
updateCarFailure
=
\u
8F66
\u
8F86
\u
4FEE
\u6539\u5931\u
8D25
deleteCarSuccess
=
\u
8F66
\u
8F86
\u5220\u9664\u6210\u
529F
deleteCarFailure
=
\u
8F66
\u
8F86
\u5220\u9664\u5931\u
8D25
\ No newline at end of file
src/main/resources/mapper/CarMapper.xml
0 → 100644
View file @
34c42b90
<?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.example.tdl.mapper.CarMapper"
>
<!--查询该公司的车辆信息-->
<select
id=
"getAll"
resultType=
"com.example.tdl.domain.vo.ResultCarVo"
parameterType=
"String"
>
SELECT carNo,type,a.img,companyName,remark
from car a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
</select>
<!--根据车牌号查询-->
<select
id=
"getByCarNo"
resultType=
"com.example.tdl.domain.vo.ResultCarVo"
parameterType=
"String"
>
SELECT carNo,type,a.img,companyName,remark
from car a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
AND carNo=#{carNo,jdbcType=VARCHAR}
</select>
<!--根据车牌号模糊查询-->
<select
id=
"getByCarNoForLike"
resultType=
"com.example.tdl.domain.vo.ResultCarVo"
parameterType=
"String"
>
SELECT carNo,type,a.img,companyName,remark
from car a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
AND carNo LIKE CONCAT(CONCAT('%',#{carNo,jdbcType=VARCHAR}), '%')
</select>
<!--添加车辆信息-->
<insert
id=
"addCar"
parameterType=
"com.example.tdl.domain.vo.ResultCarVo"
>
INSERT INTO car VALUES (
NULL ,
#{carNo,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{img,jdbcType=VARCHAR},
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}),
#{remark,jdbcType=VARCHAR}
)
</insert>
<!--修改车辆信息-->
<update
id=
"updateCar"
parameterType=
"com.example.tdl.domain.vo.UpdateCarVo"
>
UPDATE car SET
type=#{type,jdbcType=VARCHAR},
img=#{img,jdbcType=VARCHAR},
remark=#{remark,jdbcType=VARCHAR}
WHERE carNo=#{carNo,jdbcType=VARCHAR}
</update>
<!--删除车辆信息-->
<delete
id=
"delCar"
parameterType=
"String"
>
DELETE from car WHERE carNo=#{carNo,jdbcType=VARCHAR}
</delete>
</mapper>
\ No newline at end of file
src/main/resources/mybatis-config.xml
View file @
34c42b90
...
...
@@ -54,5 +54,6 @@
<mapper
resource=
"mapper/CircuitTransferMapper.xml"
/>
<mapper
resource=
"mapper/CompanyMapper.xml"
/>
<mapper
resource=
"mapper/RegionMapper.xml"
/>
<mapper
resource=
"mapper/CarMapper.xml"
/>
</mappers>
</configuration>
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