浏览代码

对点位的开关状态同步

车车 2 月之前
父节点
当前提交
4127ff3d07

+ 3 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/points/PointPageVO.java

@@ -54,6 +54,9 @@ public class PointPageVO extends BaseBean
     @ApiModelProperty(value = "所属电柜Name")
     private String lotoName;
 
+    @ApiModelProperty(value = "LOTO序列号")
+    private String lotoSerialNumber;
+
     @ApiModelProperty(value = "危险能量类型")
     private String powerType;
 

+ 6 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/ticketPoints/IsJobTicketPointsVO.java

@@ -69,6 +69,12 @@ public class IsJobTicketPointsVO extends BaseBean {
     @ApiModelProperty(value = "隔离点Name")
     private String pointName;
 
+    @ApiModelProperty(value = "lotoId")
+    private Long lotoId;
+
+    @ApiModelProperty(value = "loto序列号")
+    private String lotoSerialNumber;
+
     /**
      * 隔离点状态
      */

+ 28 - 24
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsIsolationPointServiceImpl.java

@@ -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());
+                        }
                     }
                 }
             }

+ 1 - 1
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsJobTicketServiceImpl.java

@@ -826,7 +826,7 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
         List<IsJobTicketUser> colockUserList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery().eq(IsJobTicketUser::getTicketId, ticketId).eq(IsJobTicketUser::getUserRole, isSystemAttributeService.getIsSystemAttributeByKey("role.jtcolocker").getSysAttrValue()));
         // 5.关联隔离点信息
         List<IsJobTicketPointsVO> jobTicketPointsVOList = iIsJobTicketPointsService.getListByTicketId(ticketId);
-        List<UpdateSwitchStatusDTO> switchStatusList = redisCache.getCacheList(SYS_ATTR + "sys.points.switch.records");
+        List<UpdateSwitchStatusDTO> switchStatusList = redisCache.getCacheList(SYS_ATTR + jobTicketPointsVOList.get(0).getLotoSerialNumber() + ":sys.points.switch.records");
         // 5.1获取隔离点关联的锁具数据
         List<IsJobTicketLocksetVO> ticketLocksetVOList = iIsJobTicketLocksetService.getListByTicketId(ticketId);
         for (IsJobTicketPointsVO vo : jobTicketPointsVOList) {

+ 1 - 0
ktg-iscs/src/main/resources/mapper/IsIsolationPointMapper.xml

@@ -212,6 +212,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         max(l.lock_type_img) AS lock_type_img,
         max(t.lockset_type_img) AS lockset_type_img,
         max(s.loto_name) AS loto_name,
+        max(s.loto_serial_number) AS loto_serial_number,
         max(w.workstation_name) AS workstation_name,
         STRING_AGG(ma.machinery_name, ', ') AS machinery_name,
         max(r.rfid) as point_nfc,

+ 4 - 1
ktg-iscs/src/main/resources/mapper/IsJobTicketPointsMapper.xml

@@ -126,12 +126,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             i.point_serial_number,
             l.lock_name,
             l.lock_nfc,
-            i.remark as effect
+            i.remark as effect,
+            s.loto_id,
+            s.loto_serial_number
         FROM
             is_job_ticket_points j
                 LEFT JOIN is_isolation_point i ON j.point_id = i.point_id
                 left join is_rfid_token r on r.rfid_id = i.rfid_id
                 LEFT JOIN is_lock l ON j.lock_id = l.lock_id
+                LEFT JOIN is_loto_station s ON s.loto_id = i.loto_id
         WHERE
             j.ticket_id = #{ticketId}
         ORDER BY