|
|
@@ -20,7 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ktg.common.constant.Constants.SYS_ATTR;
|
|
|
@@ -32,8 +34,7 @@ import static com.ktg.common.constant.Constants.SYS_ATTR;
|
|
|
* @date 2024-10-18
|
|
|
*/
|
|
|
@Service
|
|
|
-public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMapper, IsIsolationPoint> implements IIsIsolationPointService
|
|
|
-{
|
|
|
+public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMapper, IsIsolationPoint> implements IIsIsolationPointService {
|
|
|
@Autowired
|
|
|
private IsIsolationPointMapper isIsolationPointMapper;
|
|
|
@Autowired
|
|
|
@@ -56,8 +57,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
* @return 隔离点
|
|
|
*/
|
|
|
@Override
|
|
|
- public PointDetailVO selectIsIsolationPointByPointId(Long pointId)
|
|
|
- {
|
|
|
+ public PointDetailVO selectIsIsolationPointByPointId(Long pointId) {
|
|
|
return isIsolationPointMapper.selectIsIsolationPointByPointId(pointId);
|
|
|
}
|
|
|
|
|
|
@@ -68,8 +68,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
* @return 隔离点
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<IsIsolationPoint> selectIsIsolationPointList(IsIsolationPoint isIsolationPoint)
|
|
|
- {
|
|
|
+ public List<IsIsolationPoint> selectIsIsolationPointList(IsIsolationPoint isIsolationPoint) {
|
|
|
return isIsolationPointMapper.selectIsIsolationPointList(isIsolationPoint);
|
|
|
}
|
|
|
|
|
|
@@ -81,8 +80,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public int insertIsIsolationPoint(IsIsolationPoint isIsolationPoint)
|
|
|
- {
|
|
|
+ public int insertIsIsolationPoint(IsIsolationPoint isIsolationPoint) {
|
|
|
// 断言校验
|
|
|
Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointName()), MessageUtils.message("assert.isolation.point.name.not.null"));
|
|
|
Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointCode()), MessageUtils.message("assert.isolation.point.code.name.not.null"));
|
|
|
@@ -132,8 +130,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateIsIsolationPoint(IsIsolationPoint isIsolationPoint)
|
|
|
- {
|
|
|
+ public int updateIsIsolationPoint(IsIsolationPoint isIsolationPoint) {
|
|
|
// 断言校验
|
|
|
Assert.notNull(isIsolationPoint.getPointId(), MessageUtils.message("assert.isolation.point.id.not.null"));
|
|
|
Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointName()), MessageUtils.message("assert.isolation.point.name.not.null"));
|
|
|
@@ -167,8 +164,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteIsIsolationPointByPointIds(String pointIds)
|
|
|
- {
|
|
|
+ public int deleteIsIsolationPointByPointIds(String pointIds) {
|
|
|
Assert.notBlank(pointIds, MessageUtils.message("assert.common.delete.select.data"));
|
|
|
Long[] longIds = Convert.toLongArray(pointIds);
|
|
|
// 查询有没有sop使用改隔离点,有的话不允许删除
|
|
|
@@ -183,7 +179,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
List<Long> usedPointIds = sopPoints.stream().map(IsSopPoints::getPointId).collect(Collectors.toList());
|
|
|
List<IsIsolationPoint> isIsolationPoints = listByIds(usedPointIds);
|
|
|
List<String> usedPointNames = isIsolationPoints.stream().map(IsIsolationPoint::getPointName).collect(Collectors.toList());
|
|
|
- Assert.isTrue(false, MessageUtils.message("assert.isolation.point.name.used.by.sop.cannot.delete",usedPointNames ));
|
|
|
+ Assert.isTrue(false, MessageUtils.message("assert.isolation.point.name.used.by.sop.cannot.delete", usedPointNames));
|
|
|
}
|
|
|
// 检查电柜有没有配置该隔离点,如果还在配置中,需要先从电柜解除绑定
|
|
|
for (Long longId : longIds) {
|
|
|
@@ -211,8 +207,7 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteIsIsolationPointByPointId(Long pointId)
|
|
|
- {
|
|
|
+ public int deleteIsIsolationPointByPointId(Long pointId) {
|
|
|
return isIsolationPointMapper.deleteIsIsolationPointByPointId(pointId);
|
|
|
}
|
|
|
|
|
|
@@ -226,15 +221,24 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
|
|
|
@Override
|
|
|
public Page<PointPageVO> getIsIsolationPointPage(Page<IsIsolationPoint> page, PagePointDTO dto) {
|
|
|
Page<PointPageVO> isIsolationPointPage = isIsolationPointMapper.getIsIsolationPointPage(page, dto);
|
|
|
- List<UpdateSwitchStatusDTO> switchStatusList = redisCache.getCacheList(SYS_ATTR + "sys.points.switch.records");
|
|
|
- if (!switchStatusList.isEmpty() && !isIsolationPointPage.getRecords().isEmpty()) {
|
|
|
- for (PointPageVO pointPageVO : isIsolationPointPage.getRecords()) {
|
|
|
- for (UpdateSwitchStatusDTO updateSwitchStatusDTO : switchStatusList) {
|
|
|
- if (StringUtils.isNotBlank(pointPageVO.getPointSerialNumber())
|
|
|
- && StringUtils.isNotBlank(updateSwitchStatusDTO.getPointSerialNumber())
|
|
|
- && pointPageVO.getPointSerialNumber().equals(updateSwitchStatusDTO.getPointSerialNumber())) {
|
|
|
- pointPageVO.setSwitchStatus(updateSwitchStatusDTO.getSwitchStatus());
|
|
|
- pointPageVO.setSwitchLastUpdateTime(updateSwitchStatusDTO.getSwitchLastUpdateTime());
|
|
|
+ if (!isIsolationPointPage.getRecords().isEmpty()) {
|
|
|
+ Set<String> lotoSerialNumbers = isIsolationPointPage.getRecords().stream().map(PointPageVO::getLotoSerialNumber)
|
|
|
+ .filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
|
|
+ List<UpdateSwitchStatusDTO> switchStatusList = new ArrayList<>();
|
|
|
+ for (String lotoSerialNumber : lotoSerialNumbers) {
|
|
|
+ List<UpdateSwitchStatusDTO> cacheList = redisCache.getCacheList(SYS_ATTR + lotoSerialNumber + ":sys.points.switch.records");
|
|
|
+ switchStatusList.addAll(cacheList);
|
|
|
+ }
|
|
|
+ if (!switchStatusList.isEmpty()) {
|
|
|
+ for (PointPageVO pointPageVO : isIsolationPointPage.getRecords()) {
|
|
|
+ for (UpdateSwitchStatusDTO updateSwitchStatusDTO : switchStatusList) {
|
|
|
+ if (StringUtils.isNotBlank(pointPageVO.getPointSerialNumber())
|
|
|
+ && StringUtils.isNotBlank(updateSwitchStatusDTO.getPointSerialNumber())
|
|
|
+ && pointPageVO.getLotoSerialNumber().equals(updateSwitchStatusDTO.getLotoSerialNumber())
|
|
|
+ && pointPageVO.getPointSerialNumber().equals(updateSwitchStatusDTO.getPointSerialNumber())) {
|
|
|
+ pointPageVO.setSwitchStatus(updateSwitchStatusDTO.getSwitchStatus());
|
|
|
+ pointPageVO.setSwitchLastUpdateTime(updateSwitchStatusDTO.getSwitchLastUpdateTime());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|