|
|
@@ -1,17 +1,26 @@
|
|
|
package com.ktg.iscs.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import java.util.List;
|
|
|
-import cn.hutool.core.lang.Assert;
|
|
|
-import com.ktg.common.core.text.Convert;
|
|
|
-import com.ktg.common.utils.DateUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import com.ktg.iscs.mapper.IsMotorMapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ktg.iscs.domain.IsIsolationPoint;
|
|
|
+import com.ktg.iscs.domain.IsLotoStation;
|
|
|
+import com.ktg.iscs.domain.IsMapPoint;
|
|
|
import com.ktg.iscs.domain.IsMotor;
|
|
|
+import com.ktg.iscs.domain.dto.motor.MotorMoveDTO;
|
|
|
+import com.ktg.iscs.domain.dto.motor.MotorMoveDetailDTO;
|
|
|
+import com.ktg.iscs.mapper.IsMotorMapper;
|
|
|
+import com.ktg.iscs.service.IIsIsolationPointService;
|
|
|
+import com.ktg.iscs.service.IIsLotoStationService;
|
|
|
+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 java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 电机Service业务层处理
|
|
|
@@ -24,6 +33,12 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
|
|
|
@Autowired
|
|
|
private IsMotorMapper isMotorMapper;
|
|
|
+ @Autowired
|
|
|
+ private IIsLotoStationService isLotoStationService;
|
|
|
+ @Autowired
|
|
|
+ private IIsIsolationPointService iIsIsolationPointService;
|
|
|
+ @Autowired
|
|
|
+ private IIsMapPointService isMapPointService;
|
|
|
|
|
|
@Override
|
|
|
public Page<IsMotor> getIsMotorPage(Page<IsMotor> page, IsMotor isMotor) {
|
|
|
@@ -31,4 +46,62 @@ public class IsMotorServiceImpl extends ServiceImpl<IsMotorMapper, IsMotor> impl
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IsMotor> getIsMotorListByLotoId(Long lotoId) {
|
|
|
+ Assert.notNull(lotoId, "锁控柜id不能为空!");
|
|
|
+ IsLotoStation lotoStation = isLotoStationService.getById(lotoId);
|
|
|
+ Assert.notNull(lotoStation, "物资柜存在!");
|
|
|
+ List<IsMotor> motorList = null;
|
|
|
+ if (lotoStation.getMotorMapId() != null) {
|
|
|
+ List<IsIsolationPoint> points = iIsIsolationPointService.list(Wrappers.<IsIsolationPoint>lambdaQuery()
|
|
|
+ .eq(IsIsolationPoint::getLotoId, lotoId));
|
|
|
+ if (!points.isEmpty()) {
|
|
|
+ motorList = list(Wrappers.<IsMotor>lambdaQuery()
|
|
|
+ .in(IsMotor::getPointId, points.stream().map(IsIsolationPoint::getPointId).collect(Collectors.toList())));
|
|
|
+ if (!motorList.isEmpty()) {
|
|
|
+ // 查询这些电机有没有坐标数据
|
|
|
+ List<IsMapPoint> mapPoints = isMapPointService.list(Wrappers.<IsMapPoint>lambdaQuery()
|
|
|
+ .eq(IsMapPoint::getMapType, "4")
|
|
|
+ .eq(IsMapPoint::getMapId, lotoStation.getMotorMapId())
|
|
|
+ .in(IsMapPoint::getEntityId, motorList.stream().map(IsMotor::getMotorId).collect(Collectors.toList())));
|
|
|
+ for (IsMotor isMotor : motorList) {
|
|
|
+ for (IsMapPoint mapPoint : mapPoints) {
|
|
|
+ if (isMotor.getMotorId().equals(mapPoint.getEntityId())) {
|
|
|
+ isMotor.setX(mapPoint.getX());
|
|
|
+ isMotor.setY(mapPoint.getY());
|
|
|
+ isMotor.setMapPointId(mapPoint.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return motorList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateIsMotorMove(MotorMoveDTO dto) {
|
|
|
+ if (dto.getMapId() != null && !dto.getMoveList().isEmpty()) {
|
|
|
+ Date date = new Date();
|
|
|
+ for (MotorMoveDetailDTO motorMoveDetailDTO : dto.getMoveList()) {
|
|
|
+ if (motorMoveDetailDTO.getMapPointId() != null) {
|
|
|
+ isMapPointService.update(Wrappers.<IsMapPoint>lambdaUpdate()
|
|
|
+ .eq(IsMapPoint::getId, motorMoveDetailDTO.getMapPointId())
|
|
|
+ .set(IsMapPoint::getX, motorMoveDetailDTO.getX())
|
|
|
+ .set(IsMapPoint::getY, motorMoveDetailDTO.getY())
|
|
|
+ .set(IsMapPoint::getUpdateTime, date));
|
|
|
+ } else {
|
|
|
+ IsMapPoint isMapPoint = new IsMapPoint();
|
|
|
+ isMapPoint.setMapId(dto.getMapId());
|
|
|
+ isMapPoint.setMapType("4");
|
|
|
+ isMapPoint.setEntityId(motorMoveDetailDTO.getEntityId());
|
|
|
+ isMapPoint.setX(motorMoveDetailDTO.getX());
|
|
|
+ isMapPoint.setY(motorMoveDetailDTO.getY());
|
|
|
+ isMapPointService.save(isMapPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|