Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-miniappserver
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 3ce30ad0
authored
Jun 29, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
开发 1.9.0
1 parent
89c85255
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
875 additions
and
42 deletions
src/main/java/cn/com/glsx/app/common/constants/Constants.java
src/main/java/cn/com/glsx/app/modules/controller/DashboardController.java
src/main/java/cn/com/glsx/app/modules/controller/DeviceFreqController.java
src/main/java/cn/com/glsx/app/modules/controller/HomeController.java
src/main/java/cn/com/glsx/app/modules/entity/DeviceFreq.java
src/main/java/cn/com/glsx/app/modules/entity/DevicePower.java
src/main/java/cn/com/glsx/app/modules/mapper/DeviceFreqMapper.java
src/main/java/cn/com/glsx/app/modules/mapper/DevicePowerMapper.java
src/main/java/cn/com/glsx/app/modules/mapper/VehicleDeviceMapper.java
src/main/java/cn/com/glsx/app/modules/model/DeviceFreqModel.java
src/main/java/cn/com/glsx/app/modules/model/DeviceWorkModel.java
src/main/java/cn/com/glsx/app/modules/remote/RemoteDeviceFeignService.java
src/main/java/cn/com/glsx/app/modules/service/HomeService.java → src/main/java/cn/com/glsx/app/modules/service/DashboardService.java
src/main/java/cn/com/glsx/app/modules/service/DeviceFreqService.java
src/main/java/cn/com/glsx/app/modules/utils/JsonUtils.java
src/main/resources/mapper/DeviceFreqMapper.xml
src/main/resources/mapper/DevicePowerMapper.xml
src/main/java/cn/com/glsx/app/common/constants/Constants.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
common
.
constants
;
/**
* @Desc:公共的常量类
* @Author huangxc
* @Date 2021/5/22
*/
public
final
class
Constants
{
/**
* 删除标识 0:正常
*/
public
static
final
Integer
NORMAL_FLAG
=
0
;
/**
* 删除标识 -1:删除
*/
public
static
final
Integer
DELETE_FLAG
=
-
1
;
/**
* 广汽离线设备时间:一天 单位 s/秒 注:在sql中大多是秒,在java代码中大多是毫秒
*/
public
static
final
long
OFFLINE_TIME_GQ
=
24
*
3600L
;
/**
* 其他公司 设备离线时间:三天 单位 s/秒
*/
public
static
final
long
OFFLINE_TIME_OTHER
=
3
*
24
*
3600L
;
/**
* 有源在线时间点 6分钟 单位 毫秒/ms
*/
public
static
final
long
ONLINE_SOURCE_TIME
=
6
*
60
*
1000L
;
/**
* 字典表中车辆车型的type
*/
public
static
final
String
TRIALDRIVE_VEHICLE_MODEL
=
"trialdrive_vehicle_model"
;
/**
* 字典表中试驾车辆配置的type
*/
public
static
final
String
TRIALDRIVE_VEHICLE_CONFIG
=
"trialdrive_vehicle_config"
;
/**
* 同步渠道 timed_task:定时任务渠道
*/
public
static
final
String
SYNC_CHANNEL_TIMED_TASK
=
"edun_timed_task"
;
/**
* 厂商ID-博实结
*/
public
static
final
String
BSJ_FACTORY_ID
=
"BSJ"
;
/**
* 设备调频模式 0 追车模式;1 闹钟模式;2 星期模式;3 初始化模式
*/
public
static
final
int
ADJ_FREQ_CATCHING
=
0
;
public
static
final
int
ADJ_FREQ_TIMER
=
1
;
public
static
final
int
ADJ_FREQ_WEEK
=
2
;
public
static
final
int
ADJ_FREQ_INITIAL
=
3
;
/**
* 过滤(开)ON
*/
public
static
final
int
FILTER_GPS_BS_ON
=
1
;
/**
* 过滤(关)OFF
*/
public
static
final
int
FILTER_GPS_BS_OFF
=
0
;
/**
* xlsx 文件拓展名
*/
public
static
final
String
XLSX_FILE_EXTENSION
=
"xlsx"
;
/**
* 定位类型 GPS
*/
public
static
final
String
POI_TYPE_GPS
=
"GPS"
;
/**
* 定位类型 基站
*/
public
static
final
String
POI_TYPE_BS
=
"基站"
;
/**
* 今天
*/
public
static
final
int
TIMETYPE_TODAY
=
1
;
/**
* 昨天
*/
public
static
final
int
TIMETYPE_YESTERDAY
=
2
;
/**
* 本周
*/
public
static
final
int
TIMETYPE_THISWEEK
=
3
;
/**
* 上周
*/
public
static
final
int
TIMETYPE_LASTWEEK
=
4
;
/**
* 本月
*/
public
static
final
int
TIMETYPE_THISMONTH
=
5
;
/**
* 上月
*/
public
static
final
int
TIMETYPE_LASTMONTH
=
6
;
/**
* 时间段
*/
public
static
final
int
TIMETYPE_SCOPE
=
7
;
/**
* 时间范围 近12小时
*/
public
static
final
int
TIMETYPE_IN_12_HOURS
=
8
;
/**
* 时间范围 近24小时
*/
public
static
final
int
TIMETYPE_IN_24_HOURS
=
9
;
/**
* 近七天
*/
public
static
final
int
TIMETYPE_IN_7_DAYS
=
10
;
/**
* 近30天
*/
public
static
final
int
TIMETYPE_IN_30_DAYS
=
11
;
/**
* 时间段 带时间
*/
public
static
final
int
TIMETYPE_SCOPE_WITH_TIME
=
12
;
/**
* 包活干返回成功码
*/
public
static
final
int
BHG_RET_CODE_SUCCESS
=
200
;
/**
* 导出最大限制
*/
public
static
final
int
MAX_EXPORT_LIMIT
=
10000
;
public
static
final
String
EMPTY_CONTENT_EXCEL
=
"--"
;
}
src/main/java/cn/com/glsx/app/modules/controller/DashboardController.java
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
import
cn.com.glsx.app.modules.service.DashboardService
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 看板展示 controller
*
* @author yangll
*/
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
value
=
"/dashboard"
)
@RequestMapping
(
value
=
"/dashboard"
)
@Api
(
value
=
"看板"
,
tags
=
{
"看板"
})
@Api
(
value
=
"看板"
,
tags
=
{
"看板"
})
public
class
DashboardController
{
public
class
DashboardController
{
@Autowired
private
DashboardService
dashboardService
;
/**
* 查询设备激活趋势
*
* @param period
* @return
*/
@GetMapping
(
"getActiveDeviceInfo"
)
@ApiOperation
(
value
=
"查询设备激活趋势"
)
public
R
getActiveDeviceInfo
(
@RequestParam
Integer
period
)
{
return
R
.
ok
();
}
}
}
src/main/java/cn/com/glsx/app/modules/controller/DeviceFreqController.java
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
import
cn.com.glsx.app.modules.model.DeviceFreqModel
;
import
cn.com.glsx.app.modules.model.DeviceWorkModel
;
import
cn.com.glsx.app.modules.service.DeviceFreqService
;
import
cn.com.glsx.app.modules.service.DeviceFreqService
;
import
com.glsx.plat.common.annotation.SysLog
;
import
com.glsx.plat.common.enums.OperateType
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* 设备调频 service
* 设备调频 service
...
@@ -21,4 +29,36 @@ public class DeviceFreqController {
...
@@ -21,4 +29,36 @@ public class DeviceFreqController {
@Autowired
@Autowired
private
DeviceFreqService
deviceFreqService
;
private
DeviceFreqService
deviceFreqService
;
/**
* 一键调频
*
* @return
*/
@ApiOperation
(
value
=
"一键调频"
)
@SysLog
(
module
=
"设备调频"
,
value
=
"一键调频"
,
action
=
OperateType
.
EDIT
)
@PostMapping
(
value
=
"/adjFreq"
)
public
R
adjFreq
(
@RequestBody
DeviceWorkModel
model
)
{
if
(
StringUtils
.
isNullOrEmpty
(
model
.
getSn
()))
{
return
R
.
error
(
"sn号为空"
);
}
deviceFreqService
.
adjFreq
(
model
);
return
R
.
ok
(
"调频成功!"
);
}
/**
* 根据设备号获取调频操作详情
*
* @param sn 设备号
* @return
*/
@ApiOperation
(
value
=
"根据设备号获取调频操作详情"
)
@GetMapping
(
"/getAdjFreqInfo"
)
public
R
getAdjFreqInfo
(
@RequestParam
String
sn
)
{
if
(
StringUtils
.
isNullOrEmpty
(
sn
))
{
return
R
.
error
(
"设备号sn不能为空"
);
}
List
<
DeviceFreqModel
>
freqInfos
=
deviceFreqService
.
getAdjFreqInfo
(
sn
);
return
R
.
ok
(
"获取调频详情成功!"
).
data
(
freqInfos
);
}
}
}
src/main/java/cn/com/glsx/app/modules/controller/HomeController.java
deleted
100644 → 0
View file @
89c8525
package
cn
.
com
.
glsx
.
app
.
modules
.
controller
;
import
cn.com.glsx.app.modules.service.HomeService
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 首页统计展示 controller
*
* @author yangll
*/
@Slf4j
@RestController
@RequestMapping
(
value
=
"/home"
)
@Api
(
value
=
"看板展示"
,
tags
=
{
"看板展示"
})
public
class
HomeController
{
@Autowired
private
HomeService
homeService
;
/**
* 查询设备激活趋势
*
* @param period
* @return
*/
@GetMapping
(
"getActiveDeviceInfo"
)
@ApiOperation
(
value
=
"查询设备激活趋势"
)
public
R
getActiveDeviceInfo
(
@RequestParam
Integer
period
)
{
return
R
.
ok
();
}
}
src/main/java/cn/com/glsx/app/modules/entity/DeviceFreq.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
/**
* 调频记录
*/
@Table
(
name
=
"t_device_freq"
)
@Data
public
class
DeviceFreq
extends
BaseEntity
{
//车辆id
@Column
(
name
=
"vehicle_id"
)
private
Long
vehicleId
;
//设备号
private
String
sn
;
//调频模式0 追车模式;1 闹钟模式;2 星期模式;3 初始化模式
@Column
(
name
=
"freq_type"
)
private
Integer
freqType
;
//调频状态1 生效 ; 2 关闭
private
Integer
status
;
//设备剩余电量
@Column
(
name
=
"battery_level"
)
private
String
batteryLevel
;
//操作渠道1 APP端 ; 2 虎哥E盾系统;3 FRMS系统
private
Integer
channel
;
//追车模式下,如55
@Column
(
name
=
"catching_timer"
)
private
Integer
catchingTimer
;
//闹钟模式下,如0355,0422
private
String
timer
;
//星期模式下。如:12
private
String
week
;
//星期模式下上点时间.如1000
@Column
(
name
=
"week_timer"
)
private
String
weekTimer
;
}
src/main/java/cn/com/glsx/app/modules/entity/DevicePower.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
import
java.util.Date
;
@Data
@Table
(
name
=
"t_device_power"
)
public
class
DevicePower
extends
BaseEntity
{
/**
* 设备序列号
*/
private
String
sn
;
/**
* 车辆、设备关系id
*/
@Column
(
name
=
"vd_id"
)
private
Long
vdId
;
/**
* 电量上传时间
*/
@Column
(
name
=
"alarm_time"
)
private
Date
alarmTime
;
/**
* 设备剩余电量
*/
private
Integer
soc
;
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/DeviceFreqMapper.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
mapper
;
import
cn.com.glsx.app.modules.entity.DeviceFreq
;
import
cn.com.glsx.app.modules.model.DeviceFreqModel
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
DeviceFreqMapper
extends
CommonBaseMapper
<
DeviceFreq
>
{
/**
* 查询设备
*
* @param sn 设备号
* @return
*/
List
<
DeviceFreq
>
selectBySn
(
@Param
(
"sn"
)
String
sn
);
/**
* 获取设备调频详情
*
* @param sn 设备号
* @return
*/
List
<
DeviceFreqModel
>
getAdjFreqInfo
(
@Param
(
"sn"
)
String
sn
);
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/DevicePowerMapper.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
mapper
;
import
cn.com.glsx.app.modules.entity.DevicePower
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
DevicePowerMapper
extends
CommonBaseMapper
<
DevicePower
>
{
/**
* 根据设备号获取
*
* @param sn 设备号
* @param vdId 车辆设备绑定关系
* @return 电量信息
*/
DevicePower
selectBySn
(
@Param
(
"sn"
)
String
sn
,
@Param
(
"vdId"
)
Long
vdId
);
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/mapper/VehicleDeviceMapper.java
View file @
3ce30ad
...
@@ -3,7 +3,14 @@ package cn.com.glsx.app.modules.mapper;
...
@@ -3,7 +3,14 @@ package cn.com.glsx.app.modules.mapper;
import
cn.com.glsx.app.modules.entity.VehicleDevice
;
import
cn.com.glsx.app.modules.entity.VehicleDevice
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
@Mapper
@Mapper
public
interface
VehicleDeviceMapper
extends
CommonBaseMapper
<
VehicleDevice
>
{
public
interface
VehicleDeviceMapper
extends
CommonBaseMapper
<
VehicleDevice
>
{
@Select
(
"select * from t_vehicle_device where sn = #{sn} and bind_status = 1 and del_flag = 0 limit 1"
)
@ResultMap
(
value
=
"BaseResultMap"
)
VehicleDevice
selectBindDeviceBySn
(
@Param
(
"sn"
)
String
sn
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/app/modules/model/DeviceFreqModel.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
model
;
import
lombok.Data
;
/**
* 设备调频model
*
* @author wangchao
* @date 2018/6/19
*/
@Data
public
class
DeviceFreqModel
{
/**
* 设备号
*/
private
String
sn
;
/**
* 模式 0追车模式 1闹钟模式 2星期模式 3初始化模式
*/
private
Integer
freqType
;
/**
* 模式 0追车模式 1闹钟模式 2星期模式 3初始化模式 根据数值转换
*/
private
String
freqTypeStr
;
/**
* 闹钟模式 定点时间 逗号分隔
*/
private
String
timer
;
/**
* 星期模式 1 周一 2 周二 3 周三 4 周四 5 周五 16 周六 7 周日
*/
private
String
week
;
/**
* 星期模式 上点时间
*/
private
String
weekTimer
;
/**
* 追车模式 分钟
*/
private
String
catchingTimer
;
/**
* APP端设备调频:电量 剩余电量
*/
private
String
batteryLevel
;
/**
* 调频渠道: 1 APP端 2 网页端 3 旧E盾 4 新E盾
*/
private
Integer
channel
;
/**
* 调频状态:1 生效 2 关闭
*/
private
Integer
freqStatus
;
/**
* 调频操作人
*/
private
String
operation
;
/*
*调频时间
*/
private
String
createTime
;
private
String
vin
;
/**
* 调频模式
*/
private
String
frequency
;
/**
* 调频上点个数
*/
private
Integer
freTotal
;
private
String
activeTime
;
private
Integer
diffMinuteTime
;
private
Integer
diffDayTime
;
/**
* 设备上点总个数
*/
private
Integer
devicePointTotal
;
}
src/main/java/cn/com/glsx/app/modules/model/DeviceWorkModel.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
model
;
import
lombok.Data
;
/**
* 调频model
*/
@Data
public
class
DeviceWorkModel
{
/**
* 设备号
*/
private
String
sn
;
/**
* 模式 0追车模式 1闹钟模式 2星期模式
*/
private
int
type
;
/**
* 闹钟模式 定点时间 逗号分隔
*/
private
String
timer
;
/**
* 星期模式 1 周一 2 周二 3 周三 4 周四 5 周五 16 周六 7 周日
*/
private
String
week
;
/**
* 星期模式 上点时间
*/
private
String
weekTimer
;
/**
* 追车模式 分钟
*/
private
String
catchingTimer
;
/**
* 剩余电量
*/
private
String
batteryLevel
;
/**
* 工作时长
*/
private
String
workTime
;
}
src/main/java/cn/com/glsx/app/modules/remote/RemoteDeviceFeignService.java
0 → 100644
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
remote
;
import
cn.com.glsx.devicemonitor.api.feign.DeviceFeignService
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* @author Yanglinlong
* @date 2022/3/11 18:32
*/
@Slf4j
@Service
public
class
RemoteDeviceFeignService
{
@Autowired
private
DeviceFeignService
deviceFeignService
;
public
Integer
getDevicesTotalCount
(
String
sn
)
{
Integer
totalCount
=
0
;
R
totalCountR
=
deviceFeignService
.
getDevicesTotalCount
(
sn
);
if
(
totalCountR
!=
null
&&
totalCountR
.
isSuccess
())
{
totalCount
=
(
Integer
)
totalCountR
.
getData
();
}
return
totalCount
;
}
}
src/main/java/cn/com/glsx/app/modules/service/
Home
Service.java
→
src/main/java/cn/com/glsx/app/modules/service/
Dashboard
Service.java
View file @
3ce30ad
...
@@ -10,6 +10,6 @@ import org.springframework.stereotype.Service;
...
@@ -10,6 +10,6 @@ import org.springframework.stereotype.Service;
*/
*/
@Slf4j
@Slf4j
@Service
@Service
public
class
Home
Service
{
public
class
Dashboard
Service
{
}
}
src/main/java/cn/com/glsx/app/modules/service/DeviceFreqService.java
View file @
3ce30ad
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
package
cn
.
com
.
glsx
.
app
.
modules
.
service
;
import
cn.com.glsx.app.common.constants.Constants
;
import
cn.com.glsx.app.common.exception.AppServerException
;
import
cn.com.glsx.app.modules.entity.DeviceFreq
;
import
cn.com.glsx.app.modules.entity.DevicePower
;
import
cn.com.glsx.app.modules.entity.VehicleDevice
;
import
cn.com.glsx.app.modules.mapper.DeviceFreqMapper
;
import
cn.com.glsx.app.modules.mapper.DevicePowerMapper
;
import
cn.com.glsx.app.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.app.modules.model.DeviceFreqModel
;
import
cn.com.glsx.app.modules.model.DeviceWorkModel
;
import
cn.com.glsx.app.modules.remote.RemoteDeviceFeignService
;
import
cn.com.glsx.app.modules.utils.JsonUtils
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
com.glsx.plat.common.utils.HttpUtils
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
/**
/**
* 设备调频 service
* 设备调频 service
*
*
...
@@ -13,4 +32,172 @@ import org.springframework.stereotype.Service;
...
@@ -13,4 +32,172 @@ import org.springframework.stereotype.Service;
@Service
@Service
public
class
DeviceFreqService
{
public
class
DeviceFreqService
{
@Autowired
private
DeviceFreqMapper
deviceFreqMapper
;
@Autowired
private
VehicleDeviceMapper
vehicleDeviceMapper
;
@Autowired
private
DevicePowerMapper
devicePowerMapper
;
@Autowired
private
RemoteDeviceFeignService
remoteDeviceFeignService
;
public
void
adjFreq
(
DeviceWorkModel
model
)
{
log
.
info
(
"调频sn:"
+
model
.
getSn
()
+
"; 操作用户id:"
+
ShieldContextHolder
.
getUserId
());
List
<
DeviceFreq
>
df1
=
deviceFreqMapper
.
selectBySn
(
model
.
getSn
());
if
(
df1
!=
null
)
{
//存在
df1
.
forEach
(
deviceFreq
->
{
log
.
info
(
"存在则修改调频状态==="
+
deviceFreq
.
getId
());
deviceFreq
.
setUpdatedDate
(
new
Date
());
deviceFreq
.
setUpdatedBy
(
ShieldContextHolder
.
getUserId
());
deviceFreq
.
setStatus
(
2
);
deviceFreqMapper
.
updateByPrimaryKey
(
deviceFreq
);
});
}
DeviceFreq
df
=
new
DeviceFreq
();
String
value
=
""
;
if
(
model
.
getType
()
==
0
)
{
//追车模式
df
.
setFreqType
(
0
);
df
.
setCatchingTimer
(
Integer
.
valueOf
(
model
.
getCatchingTimer
()));
value
=
"D:"
+
model
.
getCatchingTimer
();
}
else
if
(
model
.
getType
()
==
1
)
{
//闹钟模式
df
.
setFreqType
(
1
);
df
.
setTimer
(
model
.
getTimer
());
String
transTimer
=
model
.
getTimer
().
replace
(
":"
,
""
);
value
=
"R:"
+
transTimer
;
}
else
{
//星期模式
df
.
setFreqType
(
2
);
df
.
setWeek
(
model
.
getWeek
());
df
.
setWeekTimer
(
model
.
getWeekTimer
());
String
transWeekTimer
=
model
.
getWeekTimer
().
replace
(
":"
,
""
);
value
=
"W:"
+
model
.
getWeek
()
+
","
+
transWeekTimer
;
}
//调频记录
VehicleDevice
vehicleDevice
=
vehicleDeviceMapper
.
selectBindDeviceBySn
(
model
.
getSn
());
df
.
setVehicleId
(
vehicleDevice
.
getVehicleId
());
df
.
setSn
(
model
.
getSn
());
// 设置设备电量
Long
vdId
=
Optional
.
of
(
vehicleDevice
).
map
(
VehicleDevice:
:
getId
).
orElse
(
null
);
DevicePower
devicePower
=
devicePowerMapper
.
selectBySn
(
model
.
getSn
(),
vdId
);
if
(
Objects
.
nonNull
(
devicePower
))
{
df
.
setBatteryLevel
(
devicePower
.
getSoc
()
+
""
);
}
df
.
setStatus
(
1
);
df
.
setCreatedBy
(
ShieldContextHolder
.
getUserId
());
df
.
setCreatedDate
(
new
Date
());
df
.
setUpdatedDate
(
new
Date
());
//设置操作渠道 4 新E盾系统
df
.
setChannel
(
4
);
deviceFreqMapper
.
insert
(
df
);
String
url
=
PropertiesUtils
.
getProperty
(
"bsj.adjFreq.location"
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
List
<
DeviceFreq
>
freqs
=
deviceFreqMapper
.
selectBySn
(
model
.
getSn
());
DeviceFreq
freq
=
freqs
.
get
(
0
);
params
.
put
(
"DeviceNO"
,
model
.
getSn
());
params
.
put
(
"FacID"
,
Constants
.
BSJ_FACTORY_ID
);
params
.
put
(
"Seq"
,
String
.
valueOf
(
freq
.
getId
()));
params
.
put
(
"PosRepInfo"
,
value
);
log
.
info
(
"调频参数为:"
+
params
.
toString
());
String
result
=
null
;
try
{
result
=
HttpUtils
.
post
(
url
,
params
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
log
.
info
(
"调频结果:"
+
result
+
";SN"
+
model
.
getSn
());
int
returnCode
=
(
int
)
JsonUtils
.
getProperty
(
result
,
"result"
);
if
(
returnCode
!=
0
)
{
throw
new
AppServerException
(
"调频失败"
);
}
}
public
List
<
DeviceFreqModel
>
getAdjFreqInfo
(
String
sn
)
{
List
<
DeviceFreqModel
>
freqModelList
=
deviceFreqMapper
.
getAdjFreqInfo
(
sn
);
if
(
CollectionUtils
.
isEmpty
(
freqModelList
))
{
return
freqModelList
;
}
for
(
DeviceFreqModel
model
:
freqModelList
)
{
Integer
freqType
=
model
.
getFreqType
();
if
(
Constants
.
ADJ_FREQ_CATCHING
==
freqType
)
{
//追车模式
model
.
setFrequency
(
model
.
getCatchingTimer
()
+
"分钟/点"
);
if
(
model
.
getDiffMinuteTime
()
!=
null
)
{
model
.
setFreTotal
(
model
.
getDiffMinuteTime
()
/
Integer
.
parseInt
(
model
.
getCatchingTimer
()));
}
else
{
model
.
setFreTotal
(
0
);
}
model
.
setFreqTypeStr
(
"追车模式"
);
}
else
if
(
Constants
.
ADJ_FREQ_TIMER
==
freqType
)
{
//闹钟模式
String
[]
freqArray
=
model
.
getTimer
().
split
(
","
);
StringBuilder
frequency
=
new
StringBuilder
();
for
(
String
freq
:
freqArray
)
{
frequency
.
append
(
freq
).
append
(
"/天;"
);
}
String
str
=
frequency
.
substring
(
0
,
frequency
.
length
()
-
1
);
model
.
setFrequency
(
str
);
model
.
setFreTotal
(
model
.
getDiffDayTime
()
*
freqArray
.
length
);
model
.
setFreqTypeStr
(
"闹钟模式"
);
}
else
if
(
Constants
.
ADJ_FREQ_WEEK
==
freqType
)
{
//星期模式
model
.
setFrequency
(
transWeekFrequency
(
model
.
getWeek
(),
model
.
getWeekTimer
()));
model
.
setFreTotal
((
model
.
getDiffDayTime
()
/
7
)
*
(
model
.
getWeek
().
length
()));
model
.
setFreqTypeStr
(
"星期模式"
);
}
else
if
(
Constants
.
ADJ_FREQ_INITIAL
==
freqType
)
{
//初始化模式
model
.
setFrequency
(
"10:00/天"
);
model
.
setFreTotal
(
model
.
getDiffDayTime
());
model
.
setFreqTypeStr
(
"初始化模式"
);
}
model
.
setBatteryLevel
(
model
.
getBatteryLevel
()
==
null
?
"--"
:
(
model
.
getBatteryLevel
()));
// 设置设备上点总个数
Integer
totalCount
=
remoteDeviceFeignService
.
getDevicesTotalCount
(
sn
);
model
.
setDevicePointTotal
(
totalCount
);
}
return
freqModelList
;
}
private
static
String
transWeekFrequency
(
String
week
,
String
weekTimer
)
{
StringBuilder
sb
=
new
StringBuilder
(
weekTimer
+
"/星期"
);
for
(
int
i
=
0
;
i
<
week
.
length
();
i
++)
{
char
c
=
week
.
charAt
(
i
);
switch
(
c
)
{
case
'1'
:
sb
.
append
(
"一、"
);
break
;
case
'2'
:
sb
.
append
(
"二、"
);
break
;
case
'3'
:
sb
.
append
(
"三、"
);
break
;
case
'4'
:
sb
.
append
(
"四、"
);
break
;
case
'5'
:
sb
.
append
(
"五、"
);
break
;
case
'6'
:
sb
.
append
(
"六、"
);
break
;
case
'7'
:
sb
.
append
(
"七、"
);
break
;
default
:
break
;
}
}
String
str
=
sb
.
toString
();
return
str
.
substring
(
0
,
str
.
length
()
-
1
);
}
}
}
src/main/java/cn/com/glsx/app/modules/utils/JsonUtils.java
0 → 100644
View file @
3ce30ad
/**
*
*/
package
cn
.
com
.
glsx
.
app
.
modules
.
utils
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
/**
* json 工具类
* @author yangll
*/
public
class
JsonUtils
extends
JSONUtil
{
/**
* 获取JSON返加的数据值
*
* @param jsonString JSON字符窜
* @param property 属性名称
* @return
*/
public
static
Object
getProperty
(
String
jsonString
,
String
property
)
{
JSONObject
jsonObject
=
null
;
try
{
jsonObject
=
JSONObject
.
parseObject
(
jsonString
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
jsonObject
.
get
(
property
);
}
}
src/main/resources/mapper/DeviceFreqMapper.xml
0 → 100644
View file @
3ce30ad
<?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=
"cn.com.glsx.app.modules.mapper.DeviceFreqMapper"
>
<select
id=
"selectBySn"
resultType=
"cn.com.glsx.app.modules.entity.DeviceFreq"
>
select
id ,
vehicle_id AS vehicleId,
sn,
created_date AS createdDate,
updated_date AS updatedDate,
`status`,
freq_type AS freqType,
battery_level AS batteryLevel,
channel,
catching_timer AS catchingTimer,
timer,
`week`,
week_timer AS weekTimer,
created_by AS createdBy
from t_device_freq
where sn = #{sn,jdbcType=VARCHAR}
and status=1 and del_flag = 0
</select>
<select
id=
"getAdjFreqInfo"
resultType=
"cn.com.glsx.app.modules.model.DeviceFreqModel"
>
SELECT tdf.battery_level AS batteryLevel,
LEFT(tdf.created_date, 19) AS createTime,
tdf.freq_type AS freqType,
LEFT(tv.created_date,19) AS activeTime,
tdf.channel ,
tu.username AS operation,
tdf.catching_timer AS catchingTimer,
tdf.timer ,
tdf.week ,
tdf.week_timer AS weekTimer,
TIMESTAMPDIFF(MINUTE, tdf.created_date, tdf.updated_date) AS diffMinuteTime,
TIMESTAMPDIFF(DAY, tdf.created_date, tdf.updated_date) AS diffDayTime,
tdf.sn,
tv.vin ,
tv.owner_name AS `name`,
tdf.`status` AS freqStatus
FROM t_device_freq tdf
LEFT JOIN t_vehicle tv ON tv.id = tdf.vehicle_id
LEFT JOIN t_user tu ON tu.id = tdf.created_by
WHERE tdf.sn = #{sn,jdbcType=VARCHAR}
AND tdf.status = 2
AND tdf.del_flag = 0
AND tv.del_flag = 0
ORDER BY tdf.created_date DESC
</select>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/DevicePowerMapper.xml
0 → 100644
View file @
3ce30ad
<?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=
"cn.com.glsx.app.modules.mapper.DevicePowerMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.app.modules.entity.DevicePower"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"vd_id"
jdbcType=
"INTEGER"
property=
"vdId"
/>
<result
column=
"alarm_time"
jdbcType=
"TIMESTAMP"
property=
"alarmTime"
/>
<result
column=
"soc"
jdbcType=
"INTEGER"
property=
"soc"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, sn, vd_id, alarm_time, soc, del_flag, created_date, created_by, updated_date,
updated_by
</sql>
<select
id=
"selectBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device_power
<where>
and sn = #{sn}
and vd_id = #{vdId}
and del_flag = 0
</where>
limit 1
</select>
<select
id=
"listBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device_power
<where>
and sn in
<foreach
collection=
"sn"
item=
"sn"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{sn}
</foreach>
</where>
</select>
<insert
id=
"insertOrUpdateBatch"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into t_device_power(sn, vd_id, alarm_time, soc, del_flag, created_date, created_by, updated_date, updated_by)
values
<foreach
collection=
"entities"
item=
"entity"
separator=
","
>
(#{entity.sn}, #{entity.vdId}, #{entity.alarmTime}, #{entity.soc}, #{entity.delFlag}, #{entity.createdDate}, #{entity.createdBy}, #{entity.updatedDate}, #{entity.updatedBy})
</foreach>
on duplicate key update
sn = values(sn),
vd_id = values(vd_id),
alarm_time = values(alarm_time),
soc = values(soc),
del_flag = values(del_flag),
created_date = values(created_date),
created_by = values(created_by),
updated_date = values(updated_date),
updated_by = values(updated_by)
</insert>
</mapper>
\ No newline at end of file
\ No newline at end of file
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