Bladeren bron

完善相关接口

hanzhengyi 1 week geleden
bovenliggende
commit
4a74f6d9aa

+ 2 - 2
service-sas/service-sas-biz/src/main/java/com/usky/sas/controller/web/SasEventGroupController.java

@@ -2,11 +2,11 @@ package com.usky.sas.controller.web;
 
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.CommonPage;
-import com.usky.sas.enums.SystemTypeCodeEnum;
 import com.usky.sas.service.SasEventTypeGroupService;
 import com.usky.sas.service.vo.EventGroupInfo;
 import com.usky.sas.service.vo.EventGroupPageRequest;
 import com.usky.sas.service.vo.EventGroupSaveRequest;
+import com.usky.sas.service.vo.SystemTypeCodeVO;
 import lombok.Data;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -50,7 +50,7 @@ public class SasEventGroupController {
      * GET /prod-api/service-sas/event/group/getSystemTypeCodes
      */
     @GetMapping("/getSystemTypeCodes")
-    public ApiResult<List<SystemTypeCodeEnum>> getSystemTypeCodes() {
+    public ApiResult<List<SystemTypeCodeVO>> getSystemTypeCodes() {
         return ApiResult.success(eventTypeGroupService.getSystemTypeCodes());
     }
 

+ 3 - 3
service-sas/service-sas-biz/src/main/java/com/usky/sas/domain/SasPersonTypeCode.java

@@ -8,12 +8,12 @@ import lombok.EqualsAndHashCode;
 import java.io.Serializable;
 
 /**
- * 人员类型编码表
- * 别名类,映射到 sas_people_type_code 表
+ * 出入/人员类型编码表
+ * 对应表:sas_person_type_code
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
-@TableName("sas_people_type_code")
+@TableName("sas_person_type_code")
 public class SasPersonTypeCode implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 3 - 2
service-sas/service-sas-biz/src/main/java/com/usky/sas/mapper/SasGisMapper.java

@@ -2,12 +2,13 @@ package com.usky.sas.mapper;
 
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.sas.domain.SasGis;
+import org.apache.ibatis.annotations.Param;
 
-import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 经纬度信息表 Mapper 接口
  */
 public interface SasGisMapper extends CrudMapper<SasGis> {
-    Object selectByIds(ArrayList<String> strings);
+    List<SasGis> selectByIds(@Param("ids") List<String> ids);
 }

+ 5 - 2
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/SasEventTypeGroupService.java

@@ -7,6 +7,9 @@ import com.usky.sas.enums.SystemTypeCodeEnum;
 import com.usky.sas.service.vo.EventGroupInfo;
 import com.usky.sas.service.vo.EventGroupPageRequest;
 import com.usky.sas.service.vo.EventGroupSaveRequest;
+import com.usky.sas.service.vo.SystemTypeCodeVO;
+
+import java.util.List;
 
 /**
  * 事件类型分组 服务接口
@@ -22,8 +25,8 @@ public interface SasEventTypeGroupService extends CrudService<SasEventTypeGroup>
     void delete(String id);
 
     /**
-     * 根据授权模块获取设备事件类型列表
+     * 根据授权模块获取设备事件类型列表(返回带 code、message 的 VO 列表)
      */
-    java.util.List<SystemTypeCodeEnum> getSystemTypeCodes();
+    List<SystemTypeCodeVO> getSystemTypeCodes();
 }
 

+ 29 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasDeviceServiceImpl.java

@@ -1017,6 +1017,32 @@ public class SasDeviceServiceImpl extends AbstractCrudService<SasDeviceMapper, S
         vo.setDeviceTypeName(deviceTypeName(d.getDeviceType()));
         vo.setAlarmGroupTypeName(groupName(d.getAlarsasGroupType(), false));
         vo.setVideoGroupTypeName(groupName(d.getVideoGroupType(), true));
+        // 完整报警联动组/视频监控组对象
+        if (d.getAlarsasGroupType() != null && !d.getAlarsasGroupType().isEmpty()) {
+            SasAlarsasGroupType alarmGroup = alarsasGroupTypeMapper.selectById(d.getAlarsasGroupType());
+            vo.setAlarmGroupTypes(alarmGroup);
+        }
+        if (d.getVideoGroupType() != null && !d.getVideoGroupType().isEmpty()) {
+            SasVideoMonitorGroupType videoGroup = videoMonitorGroupTypeMapper.selectById(d.getVideoGroupType());
+            vo.setVideoGroupTypes(videoGroup);
+        }
+        // 若为 NVR,则展示远端 IPC IP 地址
+        if (d.getVideoType() != null && DeviceTypeEnum.NVR.getCode().equals(d.getVideoType())
+                && d.getRemoteIpcIpAddr() != null && !d.getRemoteIpcIpAddr().isEmpty()) {
+            vo.setIpAddr(d.getRemoteIpcIpAddr());
+        }
+        // 绑定 IPC 信息
+        if (d.getBindingIpc() != null && !d.getBindingIpc().isEmpty()) {
+            SasDevice ipc = this.getById(d.getBindingIpc());
+            if (ipc != null) {
+                vo.setIpcId(ipc.getId());
+                if (ipc.getVideoType() != null && DeviceTypeEnum.NVR.getCode().equals(ipc.getVideoType())) {
+                    vo.setIpcName(ipc.getDeviceId() + "-" + ipc.getChannel());
+                } else {
+                    vo.setIpcName(ipc.getDeviceId());
+                }
+            }
+        }
         return vo;
     }
 
@@ -1055,6 +1081,9 @@ public class SasDeviceServiceImpl extends AbstractCrudService<SasDeviceMapper, S
         vo.setVideoGroupType(d.getVideoGroupType());
         vo.setAlarmGroupType(d.getAlarsasGroupType());
         vo.setNote(d.getNote());
+        vo.setVideoProtocol(d.getVideoProtocol());
+        vo.setVideoType(d.getVideoType());
+        vo.setIsBinding(d.getIsBinding());
         vo.setCreateTime(d.getCreateTime());
         vo.setUpdateTime(d.getUpdateTime());
         return vo;

+ 3 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasEventTypeGroupServiceImpl.java

@@ -16,6 +16,7 @@ import com.usky.sas.service.SasSystemActivationService;
 import com.usky.sas.service.vo.EventGroupInfo;
 import com.usky.sas.service.vo.EventGroupPageRequest;
 import com.usky.sas.service.vo.EventGroupSaveRequest;
+import com.usky.sas.service.vo.SystemTypeCodeVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -143,7 +144,7 @@ public class SasEventTypeGroupServiceImpl extends AbstractCrudService<SasEventTy
     }
 
     @Override
-    public List<SystemTypeCodeEnum> getSystemTypeCodes() {
+    public List<SystemTypeCodeVO> getSystemTypeCodes() {
         SasSystemActivation activation = systemActivationService.currentActivation();
         if (activation == null || activation.getAuthorizationModule() == null
                 || activation.getAuthorizationModule().trim().isEmpty()) {
@@ -158,6 +159,7 @@ public class SasEventTypeGroupServiceImpl extends AbstractCrudService<SasEventTy
         return codes.stream()
                 .map(SystemTypeCodeEnum::getByCode)
                 .filter(e -> e != null)
+                .map(e -> new SystemTypeCodeVO(e.getCode(), e.getMessage()))
                 .collect(Collectors.toList());
     }
 }

+ 1 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasOneStandardSixRealitiesServiceImpl.java

@@ -815,7 +815,7 @@ public class SasOneStandardSixRealitiesServiceImpl implements SasOneStandardSixR
             if (v.getGisId() != null && !v.getGisId().isEmpty()) gisIds.add(v.getGisId());
         }
         if (gisIds.isEmpty()) return Collections.emptyMap();
-        List<SasGis> gisList = (List<SasGis>) sasGisMapper.selectByIds(new ArrayList<>(gisIds));
+        List<SasGis> gisList = sasGisMapper.selectByIds(new ArrayList<>(gisIds));
         Map<String, SasGis> map = new HashMap<>(gisList.size());
         for (SasGis g : gisList) {
             map.put(g.getId(), g);

+ 105 - 2
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/impl/SasPersonnelServiceImpl.java

@@ -9,12 +9,16 @@ import com.usky.sas.domain.SasFollowPerson;
 import com.usky.sas.domain.SasPerson;
 import com.usky.sas.domain.SasCredentialTypeCode;
 import com.usky.sas.domain.SasPeopleTypeCode;
+import com.usky.sas.domain.SasPersonTypeCode;
 import com.usky.sas.mapper.SasFollowPersonMapper;
 import com.usky.sas.mapper.SasPersonMapper;
 import com.usky.sas.mapper.SasCredentialTypeCodeMapper;
 import com.usky.sas.mapper.SasPeopleTypeCodeMapper;
+import com.usky.sas.mapper.SasPersonTypeCodeMapper;
+import com.usky.sas.mapper.SasSystemConfigMapper;
 import com.usky.sas.mapper.SasVillageMapper;
 import com.usky.sas.domain.SasVillage;
+import com.usky.sas.domain.SasSystemConfig;
 import com.usky.sas.service.SasPersonnelService;
 import com.usky.sas.service.SasConfigService;
 import com.usky.sas.service.dto.agbox.JsonRpcRequest;
@@ -25,6 +29,8 @@ import com.usky.sas.service.vo.PersonnelListItem;
 import com.usky.sas.service.vo.PersonnelPageRequest;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.IdcardUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -66,6 +72,12 @@ public class SasPersonnelServiceImpl implements SasPersonnelService {
     @Autowired
     private SasVillageMapper sasVillageMapper;
 
+    @Autowired
+    private SasPersonTypeCodeMapper sasPersonTypeCodeMapper;
+
+    @Autowired
+    private SasSystemConfigMapper sasSystemConfigMapper;
+
     @Override
     public CommonPage<PersonnelListItem> whitelistPage(PersonnelPageRequest request) {
         // 目前按人员表简单分页,后续可根据白名单标识补充筛选条件
@@ -102,8 +114,99 @@ public class SasPersonnelServiceImpl implements SasPersonnelService {
 
     @Override
     public CommonPage<PersonnelListItem> registeredPage(PersonnelPageRequest request) {
-        // 在册人员同样基于人员表,后续可根据在册标识补充筛选条件
-        return buildPersonPage(request);
+        com.usky.sas.domain.SasConfig config = sasConfigService.getConfig();
+        if (config == null || config.getKeyds() == null || config.getHost() == null) {
+            log.debug("在册人员分页:未配置 AG,走本地人员表分页");
+            return buildPersonPage(request);
+        }
+        String villageCode = request.getVillageCode();
+        if (villageCode == null || villageCode.isEmpty()) {
+            villageCode = getVillageCodeForSync();
+        }
+        if (villageCode == null || villageCode.isEmpty()) {
+            log.debug("在册人员分页:无地块编码,走本地人员表分页");
+            return buildPersonPage(request);
+        }
+        int page = request.getCurrent() != null ? request.getCurrent() : 1;
+        int pageSize = request.getSize() != null ? request.getSize() : 10;
+        try {
+            String baseUrl = buildAgboxBaseUrl(config.getHost(), config.getPort());
+            String villageUrl = baseUrl + AGBOX_VILLAGE_PATH;
+            Map<String, Object> params = new HashMap<>();
+            params.put("page", page);
+            params.put("pageSize", pageSize);
+            params.put("villageCode", villageCode);
+            JsonRpcRequest getPersonJson = new JsonRpcRequest("getPerson", params, null);
+            Map<String, Object> requestBody = new HashMap<>();
+            requestBody.put("key", config.getKeyds());
+            requestBody.put("json", JSONUtil.toJsonStr(getPersonJson));
+            log.info("请求AG在册人员分页:page={}, pageSize={}, villageCode={}", page, pageSize, villageCode);
+
+            String resultStr = postWithRetry(villageUrl, requestBody);
+            PersonVo personVo = new ObjectMapper().readValue(resultStr, PersonVo.class);
+            PersonVo.PersonResult result = personVo != null ? personVo.getResult() : null;
+            List<PersonVo.PersonMsg> personList = (result != null && result.getPerson() != null) ? result.getPerson() : Collections.emptyList();
+
+            SasSystemConfig systemConfig = sasSystemConfigMapper.selectOne(new LambdaQueryWrapper<SasSystemConfig>().last("limit 1"));
+            boolean maskIdCard = systemConfig != null && Boolean.TRUE.equals(systemConfig.getMaskIdCardNo());
+
+            List<PersonnelListItem> list = personList.stream()
+                    .map(msg -> personMsgToListItem(msg, maskIdCard))
+                    .collect(Collectors.toList());
+
+            long total = (result != null && result.getCount() != null) ? result.getCount() : 0;
+            return new CommonPage<>(list, total, (long) page, (long) pageSize);
+        } catch (Exception e) {
+            log.warn("在册人员分页请求 AG 失败,回退本地人员表:{}", e.getMessage());
+            return buildPersonPage(request);
+        }
+    }
+
+    private PersonnelListItem personMsgToListItem(PersonVo.PersonMsg msg, boolean maskIdCard) {
+        PersonnelListItem item = new PersonnelListItem();
+        item.setPersonCode(msg.getPersonCode());
+        item.setName(msg.getName());
+        item.setCredentialType(msg.getCredentialType());
+        if (msg.getCredentialNo() != null) {
+            if (maskIdCard && msg.getCredentialNo().length() > 8) {
+                item.setCredentialNo(IdcardUtil.hide(msg.getCredentialNo(), 4, msg.getCredentialNo().length() - 4));
+            } else {
+                item.setCredentialNo(msg.getCredentialNo());
+            }
+        }
+        item.setPeopleTypeCode(msg.getPersonTypeCode());
+        if (msg.getFacePicUrl() != null && StrUtil.isNotBlank(msg.getFacePicUrl().getUrl()) && StrUtil.isNotBlank(msg.getFacePicUrl().getPath())) {
+            item.setPicUrl(msg.getFacePicUrl().getUrl() + msg.getFacePicUrl().getPath());
+        }
+        if (msg.getPicId() != null && !msg.getPicId().isEmpty()) {
+            item.setPicId(msg.getPicId());
+        }
+        if (msg.getUpdateTime() != null && !msg.getUpdateTime().isEmpty()) {
+            try {
+                item.setUpdateTime(LocalDateTime.parse(msg.getUpdateTime().replace(' ', 'T').substring(0, Math.min(19, msg.getUpdateTime().length())), DateTimeFormatter.ISO_LOCAL_DATE_TIME));
+            } catch (Exception ignored) {
+                item.setUpdateTime(null);
+            }
+        }
+        if (msg.getPersonEntranceTypeCode() != null) {
+            SasPersonTypeCode pt = sasPersonTypeCodeMapper.selectById(msg.getPersonEntranceTypeCode());
+            if (pt != null) {
+                item.setPersonTypeName(pt.getName());
+            }
+        }
+        if (msg.getPersonTypeCode() != null) {
+            SasPeopleTypeCode pc = sasPeopleTypeCodeMapper.selectById(String.valueOf(msg.getPersonTypeCode()));
+            if (pc != null) {
+                item.setPeopleTypeName(pc.getName());
+            }
+        }
+        if (msg.getCredentialType() != null) {
+            SasCredentialTypeCode ct = sasCredentialTypeCodeMapper.selectById(msg.getCredentialType());
+            if (ct != null) {
+                item.setCredentialTypeName(ct.getName());
+            }
+        }
+        return item;
     }
 
     @Override

+ 23 - 1
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/vo/DeviceConfigVO.java

@@ -1,5 +1,7 @@
 package com.usky.sas.service.vo;
 
+import com.usky.sas.domain.SasAlarsasGroupType;
+import com.usky.sas.domain.SasVideoMonitorGroupType;
 import lombok.Data;
 
 import java.time.LocalDateTime;
@@ -47,5 +49,25 @@ public class DeviceConfigVO {
 
     /** 视频监控组名称 */
     private String videoGroupTypeName;
-}
 
+    /** 视频协议编码(对应 sas_device.video_protocol) */
+    private Integer videoProtocol;
+
+    /** 视频设备类型编码(对应 sas_device.video_type) */
+    private Integer videoType;
+
+    /** 是否已被其他设备绑定为 IPC(对应 sas_device.is_binding) */
+    private Boolean isBinding;
+
+    /** 绑定的 IPC 设备主键ID(由 bindingIpc 解析而来) */
+    private String ipcId;
+
+    /** 绑定的 IPC 名称:IPC 为 deviceId,NVR 为 deviceId-channel */
+    private String ipcName;
+
+    /** 报警联动组完整对象(包含 id/name/note) */
+    private SasAlarsasGroupType alarmGroupTypes;
+
+    /** 视频监控组完整对象(包含 id/name/note) */
+    private SasVideoMonitorGroupType videoGroupTypes;
+}

+ 3 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/vo/PersonnelListItem.java

@@ -24,6 +24,9 @@ public class PersonnelListItem {
 
     private String peopleTypeName;
 
+    /** 出入/人员类型名称(对应 personEntranceTypeCode 解析) */
+    private String personTypeName;
+
     private Integer followPeopleType;
 
     private String followPeopleTypeName;

+ 5 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/vo/PersonnelPageRequest.java

@@ -18,6 +18,11 @@ public class PersonnelPageRequest {
      */
     private Integer size = 10;
 
+    /**
+     * 地块编码(在册人员调用 AG getPerson 时传入)
+     */
+    private String villageCode;
+
     /**
      * 姓名(模糊查询)
      */

+ 20 - 0
service-sas/service-sas-biz/src/main/java/com/usky/sas/service/vo/SystemTypeCodeVO.java

@@ -0,0 +1,20 @@
+package com.usky.sas.service.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备事件类型(用于 getSystemTypeCodes 等接口返回,显式包含 code、message)
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SystemTypeCodeVO {
+
+    /** 设备事件类型编码 */
+    private Integer code;
+
+    /** 设备事件类型名称 */
+    private String message;
+}