|
|
@@ -1,5 +1,6 @@
|
|
|
package com.ktg.iscs.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -17,7 +18,9 @@ import com.ktg.iscs.service.IIsMapPointService;
|
|
|
import com.ktg.iscs.service.IIsMotorService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -65,11 +68,13 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
.eq(IsMapPoint::getMapId, lotoStation.getMotorMapId())
|
|
|
.in(IsMapPoint::getEntityId, motorList.stream().map(IsMotor::getMotorId).collect(Collectors.toList())));
|
|
|
for (IsMotor isMotor : motorList) {
|
|
|
+ List<IsIsolationPoint> collect = points.stream().filter(o -> o.getPointId().equals(isMotor.getPointId())).collect(Collectors.toList());
|
|
|
for (IsMapPoint mapPoint : mapPoints) {
|
|
|
if (isMotor.getMotorId().equals(mapPoint.getEntityId())) {
|
|
|
isMotor.setX(mapPoint.getX());
|
|
|
isMotor.setY(mapPoint.getY());
|
|
|
isMotor.setMapPointId(mapPoint.getId());
|
|
|
+ isMotor.setPointName(collect.isEmpty() ? null : collect.get(0).getPointName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -79,11 +84,13 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
return motorList;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public Boolean updateIsMotorMove(MotorMoveDTO dto) {
|
|
|
- if (dto.getMapId() != null && !dto.getMoveList().isEmpty()) {
|
|
|
+ if (!dto.getMoveList().isEmpty()) {
|
|
|
Date date = new Date();
|
|
|
for (MotorMoveDetailDTO motorMoveDetailDTO : dto.getMoveList()) {
|
|
|
+ Assert.notNull(motorMoveDetailDTO.getMapId(), "地图主键不能为空");
|
|
|
if (motorMoveDetailDTO.getMapPointId() != null) {
|
|
|
isMapPointService.update(Wrappers.<IsMapPoint>lambdaUpdate()
|
|
|
.eq(IsMapPoint::getId, motorMoveDetailDTO.getMapPointId())
|
|
|
@@ -92,7 +99,7 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
.set(IsMapPoint::getUpdateTime, date));
|
|
|
} else {
|
|
|
IsMapPoint isMapPoint = new IsMapPoint();
|
|
|
- isMapPoint.setMapId(dto.getMapId());
|
|
|
+ isMapPoint.setMapId(motorMoveDetailDTO.getMapId());
|
|
|
isMapPoint.setMapType("4");
|
|
|
isMapPoint.setEntityId(motorMoveDetailDTO.getEntityId());
|
|
|
isMapPoint.setX(motorMoveDetailDTO.getX());
|
|
|
@@ -104,4 +111,35 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public Boolean deleteIsMotorByMotorIds(String motorIds) {
|
|
|
+ Assert.notBlank(motorIds, "请选择需要删除的数据!");
|
|
|
+ Long[] longIds = Convert.toLongArray(motorIds);
|
|
|
+ removeBatchByIds(Arrays.asList(longIds));
|
|
|
+ // 需要删除is_map_point中的相关数据
|
|
|
+ isMapPointService.remove(Wrappers.<IsMapPoint>lambdaQuery()
|
|
|
+ .eq(IsMapPoint::getMapType, "4")
|
|
|
+ .in(IsMapPoint::getEntityId, Arrays.asList(longIds)));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public Boolean updateIsMotor(IsMotor isMotor) {
|
|
|
+ IsMotor byId = getById(isMotor.getMotorId());
|
|
|
+ Assert.isTrue(byId != null, "该电机数据不存在!");
|
|
|
+ update(Wrappers.<IsMotor>lambdaUpdate()
|
|
|
+ .eq(IsMotor::getMotorId, isMotor.getMotorId())
|
|
|
+ .set(IsMotor::getMotorName, isMotor.getMotorName())
|
|
|
+ .set(IsMotor::getPointId, isMotor.getPointId() != null ? isMotor.getPointId() : null));
|
|
|
+ // 开始执行删除is_map_point数据
|
|
|
+ if (!byId.getPointId().equals(isMotor.getPointId()) || isMotor.getPointId() == null) {
|
|
|
+ isMapPointService.remove(Wrappers.<IsMapPoint>lambdaQuery()
|
|
|
+ .eq(IsMapPoint::getMapType, "4")
|
|
|
+ .eq(IsMapPoint::getEntityId, byId.getMotorId()));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|