|
@@ -10,7 +10,6 @@ import com.xy.consumer.device.push.msg.DevicePushMsgMqttConfiguration;
|
|
|
import com.xy.consumer.device.push.msg.DevicePushMsgProducer;
|
|
|
import com.xy.device.EnumDeviceActiveStatus;
|
|
|
import com.xy.device.EnumDeviceBusyStatus;
|
|
|
-import com.xy.device.EnumDeviceCharging;
|
|
|
import com.xy.device.EnumDeviceTempConfig;
|
|
|
import com.xy.dto.*;
|
|
|
import com.xy.entity.*;
|
|
@@ -56,8 +55,6 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
|
|
|
|
|
|
private DeviceInfoServiceImpl deviceInfoService;
|
|
|
|
|
|
- private DeviceChargingServiceImpl deviceChargingService;
|
|
|
-
|
|
|
private MqttServiceImpl mqttService;
|
|
|
|
|
|
private DeviceEventMsgServiceImpl deviceEventMsgService;
|
|
@@ -66,6 +63,10 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
|
|
|
|
|
|
private DeviceConfigServiceImpl deviceConfigService;
|
|
|
|
|
|
+ private DeviceChargingServiceImpl deviceChargingService;
|
|
|
+
|
|
|
+ private DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
|
+
|
|
|
@Override
|
|
|
public R save(DeviceRegisterDto.Save save) {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
@@ -141,7 +142,6 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public R active(MercMiniDeviceDto.Active active) {
|
|
|
DeviceInfo deviceInfo = deviceInfoService.getById(active.getDeviceId());
|
|
@@ -150,6 +150,10 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
|
|
|
if (deviceInfo.getActiveState().equals(activeState)) {
|
|
|
return R.fail("机器已激活");
|
|
|
}
|
|
|
+ //检查费用
|
|
|
+ R.feignCheck(deviceChargingService.check(new DeviceChargingDto.Check().setDeviceId(active.getDeviceId())));
|
|
|
+ R.feignCheck(deviceAlgorithmChargingService.check(new DeviceAlgorithmChargingDto.Check().setDeviceId(active.getDeviceId())));
|
|
|
+ //激活
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
Integer busyState = SysDictUtils.getValue(EnumDeviceBusyStatus.Code.CODE.getCode(), EnumDeviceBusyStatus.N_1.getCode(), Integer.class);
|
|
|
DeviceInfo updateDeviceInfo = new DeviceInfo()
|
|
@@ -159,17 +163,6 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
|
|
|
.setActiveTime(now)
|
|
|
.setShowStatus(true);
|
|
|
deviceInfoService.updateById(updateDeviceInfo);
|
|
|
- //首次激活可试用x天
|
|
|
- DeviceCharging deviceCharging = deviceChargingService.getById(active.getDeviceId());
|
|
|
- if (deviceCharging == null) {
|
|
|
- SysDictRedis sysDictRedis = SysDictUtils.get(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_X.getCode());
|
|
|
- deviceChargingService.save(new DeviceCharging()
|
|
|
- .setDeviceId(active.getDeviceId())
|
|
|
- .setChargingX(Integer.valueOf(sysDictRedis.getValue()))
|
|
|
- .setTimeout(now)
|
|
|
- .setCreateTime(now)
|
|
|
- );
|
|
|
- }
|
|
|
return R.ok();
|
|
|
}
|
|
|
|