hechunping 1 год назад
Родитель
Сommit
e2a58042a5

+ 13 - 0
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -591,6 +591,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         return R.ok(copy(DeviceInfoDto.Vo.class, list));
     }
 
+    @ApiOperation("根据点位ID更新坐标")
+    public R updateLonByPlaceId(@RequestBody @Validated DeviceInfoDto.UpdateLonByPlaceId dto) {
+        LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>()
+                .eq(DeviceInfo::getPlaceId, dto.getPlaceId())
+                .set(DeviceInfo::getLon, dto.getLon())
+                .set(DeviceInfo::getLat, dto.getLat());
+        update(luw);
+        return R.ok();
+    }
+
     @ApiOperation("修改")
     @PostMapping("update")
     public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
@@ -603,6 +613,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
                     .setPlaceId(update.getPlaceId())
                     .setMercId(deviceInfo.getMercId());
             mercUserBindDeviceService.bindByDeviceUpdate(bindByPlaceIdDTto);
+            //更新坐标为点位的坐标
+            MercPlaceDto.ObjVo place = mercPlaceService.obj(new MercPlaceDto.Obj().setId(update.getPlaceId())).getData();
+            update.setLat(place.getLat()).setLon(place.getLon());
         }
         DeviceInfo deviceSave = copy(DeviceInfo.class, update)
                 .setUpdateTime(LocalDateTime.now());

+ 16 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -39,6 +39,22 @@ public class DeviceInfoDto {
      */
     public final static String CLEAR = "clear";
 
+
+    @Data
+    @Accessors(chain = true)
+    public static class UpdateLonByPlaceId {
+        @NotNull(message = "点位id 不能为空")
+        @ApiModelProperty("点位id")
+        private Long placeId;
+
+        @ApiModelProperty("经度")
+        private String lon;
+
+        @ApiModelProperty("纬度")
+        private String lat;
+
+    }
+
     @Data
     @Accessors(chain = true)
     public static class SimpleDeviceSearchPageDto {

+ 2 - 0
device-api/src/main/java/com/xy/service/DeviceInfoService.java

@@ -216,6 +216,8 @@ public interface DeviceInfoService {
     @PostMapping("updateBatch")
     R updateBatch(@RequestBody List<DeviceInfoDto.Update> updates);
 
+    @PostMapping("updateLonByPlaceId")
+    R updateLonByPlaceId(@RequestBody @Validated DeviceInfoDto.UpdateLonByPlaceId dto);
     /**
      * 激活数量统计
      *