Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f425127e
authored
Sep 09, 2022
by
向延琳
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
关闭调频
1 parent
734c58b0
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
381 additions
and
19 deletions
src/main/java/cn/com/glsx/stdinterface/common/constants/Constants.java
src/main/java/cn/com/glsx/stdinterface/modules/controller/DeviceFreqController.java
src/main/java/cn/com/glsx/stdinterface/modules/entity/DeviceFreq.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DeviceFreqMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleDeviceMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/service/DeviceFreqService.java
src/main/resources/config/generatorConfig.xml
src/main/resources/mapper/AlarmWarnAlarmTypeMapper.xml
src/main/resources/mapper/DeviceFreqMapper.xml
src/main/resources/mapper/VehicleDeviceMapper.xml
src/main/java/cn/com/glsx/stdinterface/common/constants/Constants.java
View file @
f425127
...
@@ -185,4 +185,9 @@ public final class Constants {
...
@@ -185,4 +185,9 @@ public final class Constants {
*/
*/
public
static
final
int
BS
=
1
;
public
static
final
int
BS
=
1
;
}
}
/**
* 厂商ID-博实结
*/
public
static
final
String
BSJ_FACTORY_ID
=
"BSJ"
;
}
}
src/main/java/cn/com/glsx/stdinterface/modules/controller/DeviceFreqController.java
0 → 100644
View file @
f425127
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
controller
;
import
cn.com.glsx.stdinterface.api.DeviceFreqClient
;
import
cn.com.glsx.stdinterface.dto.ResetAdjFreqBO
;
import
cn.com.glsx.stdinterface.modules.service.DeviceFreqService
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author xiangyanlin
* @date 2022/9/9
*/
@Slf4j
@RestController
@RequestMapping
(
value
=
"/freq"
)
public
class
DeviceFreqController
implements
DeviceFreqClient
{
@Autowired
private
DeviceFreqService
deviceFreqService
;
@PostMapping
(
value
=
"/resetAdjFreq"
)
@Override
public
R
<
Void
>
resetAdjFreq
(
@RequestBody
ResetAdjFreqBO
resetAdjFreqBO
)
{
deviceFreqService
.
resetAdjFreq
(
resetAdjFreqBO
);
return
R
.
ok
();
}
}
src/main/java/cn/com/glsx/stdinterface/modules/entity/DeviceFreq.java
0 → 100644
View file @
f425127
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
@Data
@Table
(
name
=
"t_device_freq"
)
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系统 4 新E盾系统 5 小程序
*/
private
Integer
channel
;
/**
* 追车模式下,如55
*/
@Column
(
name
=
"catching_timer"
)
private
String
catchingTimer
;
/**
* 闹钟模式下,如0355,0422
*/
private
String
timer
;
/**
* 星期模式下。如:12
*/
private
String
week
;
/**
* 星期模式下上点时间.如10:00
*/
@Column
(
name
=
"week_timer"
)
private
String
weekTimer
;
/**
* 是否还支持调频 默认为空,汇通设备专用字段
*/
@Column
(
name
=
"support_freq"
)
private
String
supportFreq
;
/**
* 1:有账户的用户 2:分享的用户
*/
@Column
(
name
=
"user_type"
)
private
Integer
userType
;
/**
* 设备响应状态 1发送中 2已响应
*/
@Column
(
name
=
"response_status"
)
private
Integer
responseStatus
;
/**
* 持续时间,单位分钟,-1标识永久
*/
private
Integer
duration
;
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DeviceFreqMapper.java
0 → 100644
View file @
f425127
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
mapper
;
import
cn.com.glsx.stdinterface.modules.entity.DeviceFreq
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
DeviceFreqMapper
extends
CommonBaseMapper
<
DeviceFreq
>
{
/**
* 获取生效的调频记录
* @param sn 设备号
* @return 生效的调频记录
*/
DeviceFreq
selectEffectFreqBySn
(
@Param
(
"sn"
)
String
sn
);
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleDeviceMapper.java
View file @
f425127
...
@@ -4,6 +4,8 @@ import cn.com.glsx.stdinterface.modules.entity.VehicleDevice;
...
@@ -4,6 +4,8 @@ import cn.com.glsx.stdinterface.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.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -38,4 +40,15 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
...
@@ -38,4 +40,15 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
List
<
String
>
getAllUnActiveInfoSnList
();
List
<
String
>
getAllUnActiveInfoSnList
();
Integer
updateVehicleDeviceBysn
(
VehicleDevice
vehicleDevice
);
Integer
updateVehicleDeviceBysn
(
VehicleDevice
vehicleDevice
);
/**
* 根据车辆id获取关联关系
* @param vehicleId 车辆id
* @return 关联关系
*/
List
<
VehicleDevice
>
selectByVehicleId
(
Long
vehicleId
);
VehicleDevice
selectBindDeviceBySn
(
@Param
(
"sn"
)
String
sn
);
}
}
src/main/java/cn/com/glsx/stdinterface/modules/service/DeviceFreqService.java
0 → 100644
View file @
f425127
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
service
;
import
cn.com.glsx.admin.common.enums.TypeConverseEnum
;
import
cn.com.glsx.stdinterface.common.constants.Constants
;
import
cn.com.glsx.stdinterface.common.exception.StdInterfaceException
;
import
cn.com.glsx.stdinterface.dto.ResetAdjFreqBO
;
import
cn.com.glsx.stdinterface.modules.entity.DeviceFreq
;
import
cn.com.glsx.stdinterface.modules.entity.DevicePower
;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDevice
;
import
cn.com.glsx.stdinterface.modules.mapper.DeviceFreqMapper
;
import
cn.com.glsx.stdinterface.modules.mapper.DevicePowerMapper
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @author xiangyanlin
* @date 2022/9/9
*/
@Slf4j
@Service
public
class
DeviceFreqService
{
@Autowired
private
DeviceFreqMapper
deviceFreqMapper
;
@Autowired
private
VehicleDeviceMapper
vehicleDeviceMapper
;
@Autowired
private
DevicePowerMapper
devicePowerMapper
;
@Autowired
private
VehicleService
vehicleService
;
/**
* 关闭调频调频
*/
public
void
resetAdjFreq
(
ResetAdjFreqBO
resetAdjFreqBO
)
{
// 更新上个设备调频记录
updateDeviceFreqRecord
(
resetAdjFreqBO
.
getSn
(),
resetAdjFreqBO
.
getOperator
());
DeviceFreq
deviceFreq
=
new
DeviceFreq
();
//初始化模式 (默认模式 一天一个点 特殊的闹钟模式)
deviceFreq
.
setFreqType
(
TypeConverseEnum
.
FreqTypeEnum
.
INITIALIZATION_MODE
.
getFreqType
());
deviceFreq
.
setTimer
(
"15:30"
);
String
transTimer
=
"15:30"
.
replace
(
":"
,
""
);
String
value
=
"R:"
+
transTimer
;
//调频记录
VehicleDevice
vehicleDevice
=
vehicleDeviceMapper
.
selectBindDeviceBySn
(
resetAdjFreqBO
.
getSn
());
deviceFreq
.
setVehicleId
(
vehicleDevice
.
getVehicleId
());
deviceFreq
.
setSn
(
resetAdjFreqBO
.
getSn
());
// 设置设备电量
Long
vdId
=
vehicleService
.
getVdId
(
resetAdjFreqBO
.
getSn
());
DevicePower
devicePower
=
devicePowerMapper
.
selectBySn
(
resetAdjFreqBO
.
getSn
(),
vdId
);
if
(
Objects
.
nonNull
(
devicePower
))
{
deviceFreq
.
setBatteryLevel
(
devicePower
.
getSoc
()
+
""
);
}
deviceFreq
.
setStatus
(
TypeConverseEnum
.
FreqStatusEnum
.
TAKE_EFFECT
.
getFreqStatus
());
// WEB类型
deviceFreq
.
setUserType
(
TypeConverseEnum
.
UserTypeEnum
.
WEB
.
getUserType
());
deviceFreq
.
setCreatedBy
(
resetAdjFreqBO
.
getOperator
());
deviceFreq
.
setCreatedDate
(
new
Date
());
deviceFreq
.
setUpdatedDate
(
new
Date
());
//设置操作渠道 4 新E盾系统 5 小程序
deviceFreq
.
setChannel
(
4
);
deviceFreqMapper
.
insert
(
deviceFreq
);
// 向大数据侧发送调频请求
sendRequest
(
resetAdjFreqBO
.
getSn
(),
value
);
}
/**
* 发送调频请求
*
* @param sn 设备号
* @param value 调频指令
*/
private
void
sendRequest
(
String
sn
,
String
value
)
{
String
url
=
PropertiesUtils
.
getProperty
(
"bsj.adjFreq.location"
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
DeviceFreq
freq
=
deviceFreqMapper
.
selectEffectFreqBySn
(
sn
);
params
.
put
(
"DeviceNO"
,
sn
);
params
.
put
(
"FacID"
,
Constants
.
BSJ_FACTORY_ID
);
params
.
put
(
"Seq"
,
String
.
valueOf
(
freq
.
getId
()));
params
.
put
(
"PosRepInfo"
,
value
);
log
.
info
(
"调频参数为:"
+
JSONUtil
.
toJsonStr
(
params
));
String
result
=
null
;
try
{
result
=
com
.
glsx
.
plat
.
common
.
utils
.
HttpUtils
.
post
(
url
,
params
);
}
catch
(
Exception
e
)
{
log
.
info
(
"调频异常"
+
e
.
getMessage
(),
e
);
}
log
.
info
(
"调频结果:"
+
result
+
";SN"
+
sn
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
int
returnCode
=
jsonObject
.
getIntValue
(
"result"
);
if
(
returnCode
!=
0
)
{
throw
new
StdInterfaceException
(
"656565"
,
"调频失败"
);
}
}
/**
* 更新设备调频记录
*
* @param sn 设备号
*/
private
void
updateDeviceFreqRecord
(
String
sn
,
Long
operator
)
{
log
.
info
(
"调频sn:"
+
sn
+
"; 操作用户id:"
+
operator
);
DeviceFreq
deviceFreq
=
deviceFreqMapper
.
selectEffectFreqBySn
(
sn
);
if
(
Objects
.
isNull
(
deviceFreq
))
{
return
;
}
log
.
info
(
"存在则修改调频状态==="
+
deviceFreq
.
getId
());
deviceFreq
.
setUpdatedDate
(
new
Date
());
deviceFreq
.
setUpdatedBy
(
operator
);
deviceFreq
.
setStatus
(
TypeConverseEnum
.
FreqStatusEnum
.
LOSE_EFFECTIVENESS
.
getFreqStatus
());
deviceFreqMapper
.
updateByPrimaryKey
(
deviceFreq
);
}
}
src/main/resources/config/generatorConfig.xml
View file @
f425127
...
@@ -75,6 +75,6 @@
...
@@ -75,6 +75,6 @@
<!-- <table tableName="t_alarm_second_data" domainObjectName="AlarmSecondData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!-- <table tableName="t_alarm_second_data" domainObjectName="AlarmSecondData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!-- <table tableName="t_alarm_second_data_near_rel" domainObjectName="AlarmSecondDataNearRel" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!-- <table tableName="t_alarm_second_data_near_rel" domainObjectName="AlarmSecondDataNearRel" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!-- <table tableName="t_alarm_warn_analyse" domainObjectName="AlarmWarnAnalyse" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!-- <table tableName="t_alarm_warn_analyse" domainObjectName="AlarmWarnAnalyse" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table
tableName=
"t_
alarm_warn_alarm_type"
domainObjectName=
"AlarmWarnAlarmType
"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
<table
tableName=
"t_
device_freq"
domainObjectName=
"DeviceFreqDO
"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
</context>
</context>
</generatorConfiguration>
</generatorConfiguration>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/AlarmWarnAlarmTypeMapper.xml
View file @
f425127
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<!--
<!--
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
id, alarm_type, type_desc, alarm_level, del_flag, created_date, created_by, updated_date,
id, alarm_type, type_desc, alarm_level, del_flag, created_date, created_by, updated_date,
updated_by
updated_by
</sql>
</sql>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/DeviceFreqMapper.xml
0 → 100644
View file @
f425127
<?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.stdinterface.modules.mapper.DeviceFreqMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.stdinterface.modules.entity.DeviceFreq"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"vehicle_id"
jdbcType=
"INTEGER"
property=
"vehicleId"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"freq_type"
jdbcType=
"INTEGER"
property=
"freqType"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"battery_level"
jdbcType=
"VARCHAR"
property=
"batteryLevel"
/>
<result
column=
"channel"
jdbcType=
"INTEGER"
property=
"channel"
/>
<result
column=
"catching_timer"
jdbcType=
"VARCHAR"
property=
"catchingTimer"
/>
<result
column=
"timer"
jdbcType=
"VARCHAR"
property=
"timer"
/>
<result
column=
"week"
jdbcType=
"VARCHAR"
property=
"week"
/>
<result
column=
"week_timer"
jdbcType=
"VARCHAR"
property=
"weekTimer"
/>
<result
column=
"support_freq"
jdbcType=
"VARCHAR"
property=
"supportFreq"
/>
<result
column=
"user_type"
jdbcType=
"INTEGER"
property=
"userType"
/>
<result
column=
"response_status"
jdbcType=
"INTEGER"
property=
"responseStatus"
/>
<result
column=
"duration"
jdbcType=
"INTEGER"
property=
"duration"
/>
<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, vehicle_id, sn, freq_type, `status`, battery_level, channel, catching_timer,
timer, week, week_timer, support_freq, user_type, response_status, duration, del_flag,
created_date, created_by, updated_date, updated_by
</sql>
<select
id=
"selectEffectFreqBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device_freq
<where>
and sn = #{sn,jdbcType=VARCHAR}
and status=1
and del_flag = 0
</where>
limit 1
</select>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/VehicleDeviceMapper.xml
View file @
f425127
...
@@ -84,33 +84,55 @@
...
@@ -84,33 +84,55 @@
</select>
</select>
<select
id=
"getUnActiveInfoSnList"
resultType=
"java.lang.String"
>
<select
id=
"getUnActiveInfoSnList"
resultType=
"java.lang.String"
>
select
select sn
sn
from t_vehicle_device
from t_vehicle_device
where del_flag = 0
where del_flag = 0
and bind_status = 1
and bind_status = 1
and left(created_date,
10)
<![CDATA[ >= ]]>
#{dayTimeFormat}
and left(created_date,
10)
<![CDATA[ >= ]]>
#{dayTimeFormat}
and active_location_date is null
and active_location_date is null
</select>
</select>
<select
id=
"getAllUnActiveInfoSnList"
resultType=
"java.lang.String"
>
<select
id=
"getAllUnActiveInfoSnList"
resultType=
"java.lang.String"
>
select sn
select sn
from t_vehicle_device
from t_vehicle_device
where del_flag = 0
where del_flag = 0
and bind_status = 1
and bind_status = 1
and active_location_date is null
and active_location_date is null
</select>
</select>
<update
id=
"updateVehicleDeviceBysn"
>
<update
id=
"updateVehicleDeviceBysn"
>
update t_vehicle_device
update t_vehicle_device
set
set active_location_date = #{activeLocationDate},
active_location_date = #{activeLocationDate},
active_location_type = #{activeLocationType},
active_location_type = #{activeLocationType},
active_location_lat = #{activeLocationLat},
active_location_lat = #{activeLocationLat},
active_location_lng = #{activeLocationLng},
active_location_lng = #{activeLocationLng},
active_location_address = #{activeLocationAddress}
active_location_address = #{activeLocationAddress}
where sn = #{sn}
where sn = #{sn}
and del_flag = 0
and del_flag = 0
and bind_status = 1
and bind_status = 1
</update>
</update>
<select
id=
"selectByVehicleId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_vehicle_device
<where>
and bind_status = 1
and del_flag = 0
and vehicle_id = #{vehicleId}
</where>
order by id
</select>
<select
id=
"selectBindDeviceBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_vehicle_device
<where>
sn = #{sn}
and bind_status = 1
and del_flag = 0
limit 1
</where>
</select>
</mapper>
</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