Browse Source

Merge branch '点位'

hechunping 1 year ago
parent
commit
e08724e816

+ 18 - 3
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.lang.Console;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.text.StrBuilder;
 import cn.hutool.core.text.StrBuilder;
 import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.BooleanUtil;
@@ -112,6 +113,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
 
     private final MercPlaceService mercPlaceService;
     private final MercPlaceService mercPlaceService;
 
 
+    private final MercUserBindDeviceService mercUserBindDeviceService;
+
 
 
     @Override
     @Override
     @ApiOperation("设备列表-管理员")
     @ApiOperation("设备列表-管理员")
@@ -591,10 +594,22 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     @ApiOperation("修改")
     @ApiOperation("修改")
     @PostMapping("update")
     @PostMapping("update")
     public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
     public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
-        DeviceInfo deviceInfo = copy(DeviceInfo.class, update)
+        DeviceInfo deviceInfo = getById(update.getDeviceId());
+        //判断是否更新了点位
+        if(Emptys.check(update.getPlaceId()) && !Objects.equals(deviceInfo.getPlaceId(),update.getPlaceId())){
+            //把设备绑定给点位管理员
+            MercUserBindDeviceDto.BindByDeviceUpdate bindByPlaceIdDTto = new MercUserBindDeviceDto.BindByDeviceUpdate();
+            bindByPlaceIdDTto.setDeviceId(update.getDeviceId())
+                    .setPlaceId(update.getPlaceId())
+                    .setMercId(deviceInfo.getMercId());
+            mercUserBindDeviceService.bindByDeviceUpdate(bindByPlaceIdDTto);
+        }
+        DeviceInfo deviceSave = copy(DeviceInfo.class, update)
                 .setUpdateTime(LocalDateTime.now());
                 .setUpdateTime(LocalDateTime.now());
-        updateById(deviceInfo);
-        Long deviceId = deviceInfo.getDeviceId();
+        updateById(deviceSave);
+
+
+        Long deviceId = deviceSave.getDeviceId();
         DeviceInfoDto.Vo device = R.feignCheckData(this.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(true)));
         DeviceInfoDto.Vo device = R.feignCheckData(this.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(true)));
         Long algorithmId = update.getAlgorithmId();
         Long algorithmId = update.getAlgorithmId();
         if (algorithmId != null && AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
         if (algorithmId != null && AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {