DeviceService.java
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.constants.ConstantsDevice;
import cn.com.glsx.admin.modules.entity.Device;
import cn.com.glsx.admin.modules.entity.VehicleDevice;
import cn.com.glsx.admin.modules.mapper.DeviceMapper;
import cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Desc:设备service
* @Author huangxc
* @Date 2021/5/23
*/
@Service
public class DeviceService {
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private VehicleDeviceMapper vdMapper;
public void insertDevice(Device device) {
deviceMapper.insert(device);
}
Device getDeviceBySn(String sn) {
return deviceMapper.getDeviceBySn(sn);
}
/**
* 检查设备号是否存在 false 不存在
* @param sn
*/
public boolean checkSnExist(String sn) {
Device device = deviceMapper.getDeviceBySn(sn);
if (device == null) {
return false;
}
return true;
}
/**
* 检查设备号是否绑定 false 没有绑定
* @param sn
*/
public boolean checkSnBind(String sn) {
VehicleDevice vehicleDeviceParam = new VehicleDevice();
vehicleDeviceParam.setSn(sn);
VehicleDevice vehicleDevice = vdMapper.getVehicleDeviceBySnStatus(vehicleDeviceParam);
if (vehicleDevice != null && vehicleDevice.getBindStatus() == ConstantsDevice.BIND_VEHICLE_STATUS) {
return true;
}
return false;
}
}