Bläddra i källkod

Merge branch 'refs/heads/master' into master-碰一下

tanbin 8 månader sedan
förälder
incheckning
a8d6be5e22

+ 10 - 2
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -678,14 +678,22 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         Long deviceId = deviceSave.getDeviceId();
         DeviceInfoDto.Vo device = R.feignCheckData(this.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(true)));
         Long algorithmId = update.getAlgorithmId();
-        if (algorithmId != null && AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
+        //切换算法逻辑处理
+        if (algorithmId != null && !Objects.equals(deviceInfo.getAlgorithmId(), algorithmId)) {
+            //1、删除设备商品
+            GoodsDeviceDto.DelByDeviceId delByDeviceId = new GoodsDeviceDto.DelByDeviceId();
+            delByDeviceId.setDeviceId(deviceId);
+            delByDeviceId.setMercId(delByDeviceId.getMercId());
+            R.feignCheckData(goodsDeviceService.delByDeviceId(delByDeviceId));
+        }
+        if (algorithmId != null && Objects.equals(AlgorithmTypeEnum.CLOUD.getId(), algorithmId)) {
             // 云从算法
             boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
             if (!b) {
                 // 货柜不存在,新增
                 cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
             }
-        } else if (algorithmId != null && AlgorithmTypeEnum.TY.getId() == algorithmId) {
+        } else if (algorithmId != null && Objects.equals(AlgorithmTypeEnum.TY.getId(), algorithmId)) {
             // 拓元算法
             // 查询登记设备
             DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));

+ 3 - 2
device-api-service/src/main/java/com/xy/service/factory/device/impl/open/OpenDeviceFactoryImpl.java

@@ -2,6 +2,7 @@ package com.xy.service.factory.device.impl.open;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
@@ -210,9 +211,9 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
                 //  NFC 支付宝碰一下激活
                 ActiveDeviceDTO activeDeviceDTO = new ActiveDeviceDTO().setTerminalId(String.valueOf(deviceId))
                         .setDeviceName(deviceName)
-                        .setBoardSn(deviceSysinfo.getDeviceSn()).setNfcSn(deviceSysinfo.getNfcSn()).setAddress(dv.getPlaceName());
+                        .setBoardSn(nfcSn).setNfcSn(nfcSn).setAddress(dv.getPlaceName());
                 Boolean b = R.feignCheckData(alipayDeviceService.nfcDeviceActive(activeDeviceDTO));
-                if (b) {
+                if (BooleanUtil.isFalse(b)) {
                     throw new RuntimeException("NFC设备激活失败!");
                 }
             }