Explorar el Código

北向接口代码优化提交

jingyuanchao hace 1 año
padre
commit
b889920a2e

+ 1 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotDeviceServiceImpl.java

@@ -56,6 +56,7 @@ public class IotDeviceServiceImpl extends ServiceImpl<IotDeviceMapper, IotDevice
         return lambdaQuery()
                 .eq(IotDevice::getOrgId, orgId)
                 .eq(IotDevice::getEquipmentCode, equipmentCode)
+                .eq(IotDevice::getDeleted, 0)
                 .last(Constants.LIMIT1)
                 .one();
     }

+ 2 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotDvrChannelServiceImpl.java

@@ -61,9 +61,10 @@ public class IotDvrChannelServiceImpl extends ServiceImpl<IotDvrChannelMapper, I
     @Override
     public IotDvrChannel findChannel(String channelCode, String equipmentCode, Long orgId) {
         return lambdaQuery()
-                .eq(IotDvrChannel::getHostCode, equipmentCode)
                 .eq(IotDvrChannel::getOrgId, orgId)
+                .eq(IotDvrChannel::getHostCode, equipmentCode)
                 .eq(IotDvrChannel::getChannelCode, channelCode)
+                .eq(IotDvrChannel::getDeleted, 0)
                 .last(Constants.LIMIT1)
                 .one();
     }

+ 18 - 35
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/VideoDaysCheckServiceImpl.java

@@ -87,34 +87,34 @@ public class VideoDaysCheckServiceImpl extends ServiceImpl<VideoDaysCheckMapper,
         String organizationGuid = videoDaysCheckDto.getOrganizationGuid();
         SysOrg org = orgService.findByCode(organizationGuid, SecurityConstants.INNER);
         if (org == null) {
-            NorthError error = new NorthError(msgId,"/video/daysInfo"
-                    , videoDaysCheckDto, "参数非法:organizationGuid:" + organizationGuid + "不正确");
-            northErrorService.saveError(error);
-            return ReceiveErrorDto.success();
+            northErrorService.saveError(new NorthError(msgId, "/video/daysInfo", videoDaysCheckDto, "参数非法:organizationGuid:" + organizationGuid + "不正确"));
+            return ReceiveErrorDto.error("参数非法:organizationGuid:" + organizationGuid + "不正确");
         }
-        MediatorVideoDaysCheck videoDaysCheck = new MediatorVideoDaysCheck();
-
-        //获取监控主机
         IotDevice hostDevice = iIotDeviceService.findByHostCode(videoDaysCheckDto.getEquipmentCode(), org.getId());
-        if (hostDevice != null) {
-            videoDaysCheck.setEquipmentName(hostDevice.getEquipmentName());
+        if (ObjectUtil.isNull(hostDevice)) {
+            northErrorService.saveError(new NorthError(msgId, "/video/daysInfo", videoDaysCheckDto, "主机不存在!"));
+            return ReceiveErrorDto.error("主机不存在!");
         }
-
-        MediatorVideoDaysCheck old = this.findByOrgIdAndEquipmentCodeAndChannelCode(org.getId(), videoDaysCheckDto.getEquipmentCode(), videoDaysCheckDto.getChannelCode());
-        if (old != null) {
-            videoDaysCheck = old;
+        final IotDvrChannel channel = dvrChannelService.findChannel(videoDaysCheckDto.getChannelCode(), videoDaysCheckDto.getEquipmentCode(), org.getId());
+        if (ObjectUtil.isNull(channel)) {
+            northErrorService.saveError(new NorthError(msgId, "/video/daysInfo", videoDaysCheckDto, "通道/设备不存在!"));
+            return ReceiveErrorDto.error("通道/设备不存在!");
         }
-        if (old == null) {
+        MediatorVideoDaysCheck videoDaysCheck = this.findByOrgIdAndEquipmentCodeAndChannelCode(org.getId(), videoDaysCheckDto.getEquipmentCode(), videoDaysCheckDto.getChannelCode());
+        if (videoDaysCheck == null) {
+            videoDaysCheck = new MediatorVideoDaysCheck();
             videoDaysCheck.setCreateTime(new Date());
         }
+        //获取监控主机
+        videoDaysCheck.setEquipmentName(hostDevice.getEquipmentName());
+        videoDaysCheck.setEquipmentCode(videoDaysCheckDto.getEquipmentCode());
         videoDaysCheck.setUpdateTime(new Date());
         videoDaysCheck.setChannelCode(videoDaysCheckDto.getChannelCode());
         videoDaysCheck.setChannelName(videoDaysCheckDto.getChannelName());
-        if (ObjectUtil.isNotEmpty(videoDaysCheckDto.getCheckDate())){
+        if (ObjectUtil.isNotEmpty(videoDaysCheckDto.getCheckDate())) {
             videoDaysCheck.setCheckDate(JSON.toJSONString(videoDaysCheckDto.getCheckDate()));
         }
-        videoDaysCheck.setEquipmentCode(videoDaysCheckDto.getEquipmentCode());
-        if (ObjectUtil.isNotEmpty(videoDaysCheckDto.getLoseDate())){
+        if (ObjectUtil.isNotEmpty(videoDaysCheckDto.getLoseDate())) {
             videoDaysCheck.setLoseDate(JSON.toJSONString(videoDaysCheckDto.getLoseDate()));
         }
         videoDaysCheck.setPlanDays(videoDaysCheckDto.getPlanDays());
@@ -122,32 +122,15 @@ public class VideoDaysCheckServiceImpl extends ServiceImpl<VideoDaysCheckMapper,
         videoDaysCheck.setOrgId(org.getId());
         videoDaysCheck.setOrgName(org.getShortName());
         videoDaysCheck.setOrgPath(org.getPath());
-        if(ObjectUtil.isNotEmpty(videoDaysCheckDto.getEarliestVideoTime())){
+        if (ObjectUtil.isNotEmpty(videoDaysCheckDto.getEarliestVideoTime())) {
             videoDaysCheck.setEarliestVideoTime(LocalDateTime.parse(videoDaysCheckDto.getEarliestVideoTime(), DateTimeFormatter.ISO_DATE_TIME));
         }
         videoDaysCheck.setStatus(0);
         if (ObjectUtil.isAllNotEmpty(videoDaysCheck.getCheckDate(), videoDaysCheck.getLoseDate()) && !"null".equals(videoDaysCheck.getLoseDate()) && !"null".equals(videoDaysCheck.getCheckDate()) && !"[]".equals(videoDaysCheck.getLoseDate()) && !"[]".equals(videoDaysCheck.getCheckDate())) {
             final Map map = JSON.parseObject(videoDaysCheck.getCheckDate(), Map.class);
             final List list = JSON.parseObject(videoDaysCheck.getLoseDate(), List.class);
-            /*final String dateStr = (String) map.get("sd");
-            final DateTime offsetDay1 = DateUtil.offsetDay(DateUtil.parse(dateStr), 1);
-            final DateTime offsetDay2 = DateUtil.offsetDay(DateUtil.parse(dateStr), 2);
-            final String dateStr1 = DateUtil.format(offsetDay1, "yyyy-MM-dd");
-            final String dateStr2 = DateUtil.format(offsetDay2, "yyyy-MM-dd");*/
-
-            //2023/1/17 v1.9.4版本需求,判断从三天改成一天
-            //videoDaysCheck.setStatus(list.contains(dateStr1) && list.contains(dateStr2) && list.contains(map.get("sd")) ? 1 : 0);
             videoDaysCheck.setStatus(list.contains(map.get("sd")) ? 1 : 0);
         }
-
-
-        final IotDvrChannel channel = dvrChannelService.findChannel(videoDaysCheckDto.getChannelCode(), videoDaysCheckDto.getEquipmentCode(), org.getId());
-        if (ObjectUtil.isNull(channel)) {
-            NorthError error = new NorthError(msgId,"/video/daysInfo"
-                    , videoDaysCheckDto, "通道/设备不存在!");
-            northErrorService.saveError(error);
-            return ReceiveErrorDto.success();
-        }
         this.saveOrUpdate(videoDaysCheck);
         saveLog(videoDaysCheck);
         return ReceiveErrorDto.success();

+ 2 - 6
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/VideoIntegrityCheckServiceImpl.java

@@ -84,16 +84,12 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
         String organizationGuid = videoIntegrityCheckDto.getOrganizationGuid();
         SysOrg org = orgService.findByCode(organizationGuid, SecurityConstants.INNER);
         if (org == null) {
-            NorthError error = new NorthError(msgId, "/video/complete"
-                    , videoIntegrityCheckDto, "参数非法:organizationGuid:" + organizationGuid + "不正确");
-            northErrorService.saveError(error);
+            northErrorService.saveError(new NorthError(msgId, "/video/complete", videoIntegrityCheckDto, "参数非法:organizationGuid:" + organizationGuid + "不正确"));
             return ReceiveErrorDto.success();
         }
         final IotDvrChannel channel = dvrChannelService.findChannel(videoIntegrityCheckDto.getChannelCode(), videoIntegrityCheckDto.getEquipmentCode(), org.getId());
         if (ObjectUtil.isNull(channel)) {
-            NorthError error = new NorthError(msgId, "/video/complete"
-                    , videoIntegrityCheckDto, "通道/设备不存在");
-            northErrorService.saveError(error);
+            northErrorService.saveError(new NorthError(msgId, "/video/complete", videoIntegrityCheckDto, "通道/设备不存在"));
             return ReceiveErrorDto.success();
         }