|
@@ -57,28 +57,37 @@ import static com.xy.utils.Beans.copy;
|
|
|
@Api(tags = "小程序-设备")
|
|
|
public class MercMiniDeviceController {
|
|
|
|
|
|
+ /**
|
|
|
+ * auth-code有效期30分钟,单位:s ,
|
|
|
+ */
|
|
|
+ public static final Integer AUTH_CODE_TIMEOUT = 1800;
|
|
|
private final MercFeignService mercFeignService;
|
|
|
-
|
|
|
private final DeviceInfoServiceImpl deviceInfoService;
|
|
|
-
|
|
|
private final DeviceSysinfoServiceImpl deviceSysinfoService;
|
|
|
-
|
|
|
private final MercPlaceService mercPlaceService;
|
|
|
-
|
|
|
private final MercLineService mercLineService;
|
|
|
-
|
|
|
private final DeviceBluetoothAuthServiceImpl deviceBluetoothAuthService;
|
|
|
-
|
|
|
private final DeviceTempRecordsServiceImpl deviceTempRecordsService;
|
|
|
-
|
|
|
private final AlipayDeviceService alipayDeviceService;
|
|
|
-
|
|
|
private final DeviceStatusServiceImpl deviceStatusService;
|
|
|
-
|
|
|
private final DeviceConfigServiceImpl deviceConfigService;
|
|
|
-
|
|
|
private final DeviceTempSetServiceImpl deviceTempSetService;
|
|
|
|
|
|
+ public static void setCacheAuthCode(Long deviceId, String code) {
|
|
|
+ RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
+ redisService.set("device:auth:code:" + deviceId, code, AUTH_CODE_TIMEOUT);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getCacheAuthCode(Long deviceId) {
|
|
|
+ RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
+ return redisService.get("device:auth:code:" + deviceId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void delCacheAuthCode(Long deviceId) {
|
|
|
+ RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
+ redisService.remove("device:auth:code:" + deviceId);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("解绑商户")
|
|
|
@PostMapping("unBindMercDevice")
|
|
|
R<Boolean> unBindMercDevice(@RequestBody @Validated DeviceInfoDto.MercDeviceUnBindDto dto) {
|
|
@@ -151,7 +160,6 @@ public class MercMiniDeviceController {
|
|
|
return deviceInfoService.mercHomeStatistical(dto);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@ApiOperation("设备列表-Id&Name")
|
|
|
@PostMapping("listOfIdName")
|
|
|
public R listOfIdName() {
|
|
@@ -193,9 +201,13 @@ public class MercMiniDeviceController {
|
|
|
Long placeId = vo.getPlaceId();
|
|
|
List<MercPlaceDto.Vo> merPlaceList = R.feignCheckData(mercPlaceService.list(new MercPlaceDto.ListDto().setIds(CollUtil.newArrayList(placeId))));
|
|
|
MercPlaceDto.Vo mercPlace = CollUtil.isNotEmpty(merPlaceList) ? merPlaceList.get(0) : null;
|
|
|
- vo.setPlaceName(mercPlace == null ? StrUtil.EMPTY : mercPlace.getPlaceName());
|
|
|
+ if (Emptys.check(mercPlace)) {
|
|
|
+ vo.setDistrictName(mercPlace.getRegionName());
|
|
|
+ vo.setPlaceName(mercPlace.getPlaceName());
|
|
|
+ }
|
|
|
+
|
|
|
//返显区域名称
|
|
|
- vo.setDistrictName(mercPlace.getRegionName());
|
|
|
+
|
|
|
DeviceStatusDto.Vo deviceStatus = vo.getDeviceStatus();
|
|
|
vo.setNetStateName(deviceStatus == null ? StrUtil.EMPTY : DeviceNetSateType.getEnumByCode(deviceStatus.getNetState()).getDescription());
|
|
|
if (deviceStatus != null) {
|
|
@@ -359,14 +371,12 @@ public class MercMiniDeviceController {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@ApiOperation("当前登录用户拥有的设备")
|
|
|
@PostMapping("myDevices")
|
|
|
R<List<Long>> myDevices() {
|
|
|
return R.ok(getMyDevices());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取登录人的设备
|
|
|
*
|
|
@@ -431,7 +441,6 @@ public class MercMiniDeviceController {
|
|
|
return R.ok(deviceBluetoothAuthService.save(saveInfo));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@PostMapping("verificationCode")
|
|
|
@ApiOperation("蓝牙开门-校验并使用授权码")
|
|
|
public R<Boolean> verificationCode(@RequestBody @Validated DeviceBluetoothAuthDto.VerificationCode dto) {
|
|
@@ -465,26 +474,4 @@ public class MercMiniDeviceController {
|
|
|
return R.ok(deviceBluetoothAuthService.saveOrUpdate(deviceBluetoothAuth));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * auth-code有效期30分钟,单位:s ,
|
|
|
- */
|
|
|
- public static final Integer AUTH_CODE_TIMEOUT = 1800;
|
|
|
-
|
|
|
-
|
|
|
- public static void setCacheAuthCode(Long deviceId, String code) {
|
|
|
- RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
- redisService.set("device:auth:code:" + deviceId, code, AUTH_CODE_TIMEOUT);
|
|
|
- }
|
|
|
-
|
|
|
- public static String getCacheAuthCode(Long deviceId) {
|
|
|
- RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
- return redisService.get("device:auth:code:" + deviceId);
|
|
|
- }
|
|
|
-
|
|
|
- public static void delCacheAuthCode(Long deviceId) {
|
|
|
- RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
|
|
|
- redisService.remove("device:auth:code:" + deviceId);
|
|
|
- }
|
|
|
-
|
|
|
}
|