From 64efb660b2c119c00432434c0f651f8996483f18 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 21 二月 2025 15:51:13 +0800
Subject: [PATCH] OSD大华数据格式+数据中心重点标签统计数

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java |  180 ++++++++++++++++++++++-------------------------------------
 1 files changed, 67 insertions(+), 113 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java
index 43a9293..4735150 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckRuleServiceImpl.java
@@ -1,154 +1,108 @@
 package com.ycl.platform.service.impl;
 
-import com.ycl.platform.domain.entity.CheckRule;
-import com.ycl.platform.domain.entity.YwUnit;
-import com.ycl.platform.mapper.CheckRuleMapper;
-import com.ycl.platform.service.CheckRuleService;
-import com.ycl.system.Result;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ycl.platform.domain.form.CheckRuleForm;
+import com.ycl.platform.domain.entity.CheckRule;
 import com.ycl.platform.domain.vo.CheckRuleVO;
-import com.ycl.platform.domain.query.CheckRuleQuery;
-import java.util.List;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.ycl.system.page.PageUtil;
-import com.ycl.utils.DateUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.security.core.context.SecurityContextHolder;
+import com.ycl.platform.mapper.CheckRuleMapper;
+import com.ycl.platform.service.ICheckRuleService;
+import constant.CheckConstants;
+import org.hibernate.annotations.Check;
 import org.springframework.beans.BeanUtils;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.Assert;
-import java.util.ArrayList;
-import java.util.Objects;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import utils.DateUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
-import lombok.RequiredArgsConstructor;
-import org.springframework.util.StringUtils;
 
 /**
- * 鑰冩牳瑙勫垯 鏈嶅姟瀹炵幇绫�
- *
- * @author xp
- * @since 2024-03-06
+ * 鑰冩牳瑙勫垯Service涓氬姟灞傚鐞�
+ * 
+ * @author ruoyi
+ * @date 2024-04-15
  */
 @Service
-@RequiredArgsConstructor
-public class CheckRuleServiceImpl extends ServiceImpl<CheckRuleMapper, CheckRule> implements CheckRuleService {
-
-    private final CheckRuleMapper checkRuleMapper;
+public class CheckRuleServiceImpl extends ServiceImpl<CheckRuleMapper, CheckRule> implements ICheckRuleService
+{
+    @Autowired
+    private CheckRuleMapper checkRuleMapper;
 
     /**
-     * 娣诲姞
-     * @param form
-     * @return
+     * 鏌ヨ鑰冩牳瑙勫垯
+     * @param id 鑰冩牳瑙勫垯涓婚敭
+     * @return 鑰冩牳瑙勫垯
      */
     @Override
-    public Result add(CheckRuleForm form) {
-        CheckRule entity = CheckRuleForm.getEntityByForm(form, null);
-        if(baseMapper.insert(entity) > 0) {
-            return Result.ok("娣诲姞鎴愬姛");
-        }
-        return Result.error("娣诲姞澶辫触");
+    public CheckRule selectCheckRuleById(Long id)
+    {
+        return checkRuleMapper.selectCheckRuleById(id);
     }
 
     /**
-     * 淇敼
-     * @param form
-     * @return
+     * 鏌ヨ鑰冩牳瑙勫垯鍒楄〃
+     * 
+     * @param checkRule 鑰冩牳瑙勫垯
+     * @return 鑰冩牳瑙勫垯
      */
     @Override
-    public Result update(CheckRuleForm form) {
-
-        CheckRule entity = baseMapper.selectById(form.getId());
-
-        // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
-        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
-        BeanUtils.copyProperties(form, entity);
-        if (baseMapper.updateById(entity) > 0) {
-            return Result.ok("淇敼鎴愬姛");
-        }
-        return Result.error("淇敼澶辫触");
+    public CheckRuleVO selectCheckRuleList(CheckRule checkRule)
+    {
+        List<CheckRule> checkRules = checkRuleMapper.selectCheckRuleList(checkRule);
+        Map<Short, List<CheckRule>> map = checkRules.stream().collect(Collectors.groupingBy(CheckRule::getRuleCategory));
+        CheckRuleVO checkRuleVO = new CheckRuleVO()
+                .setCarRules(map.get(CheckConstants.Rule_Category_Car))
+                .setFaceRules(map.get(CheckConstants.Rule_Category_Face))
+                .setVideoRules(map.get(CheckConstants.Rule_Category_Video));
+        return checkRuleVO;
     }
 
     /**
-     * 鎵归噺鍒犻櫎
-     * @param ids
-     * @return
+     * 鏂板鑰冩牳瑙勫垯
+     * 
+     * @param checkRule 鑰冩牳瑙勫垯
+     * @return 缁撴灉
      */
     @Override
-    public Result remove(List<String> ids) {
-        if(baseMapper.deleteBatchIds(ids) > 0) {
-            return Result.ok("鍒犻櫎鎴愬姛");
-        }
-        return Result.error("鍒犻櫎澶辫触");
+    public int insertCheckRule(CheckRule checkRule)
+    {
+        return checkRuleMapper.insertCheckRule(checkRule);
     }
 
     /**
-     * id鍒犻櫎
-     * @param id
-     * @return
+     * 淇敼鑰冩牳瑙勫垯
+     * @param checkRule 鑰冩牳瑙勫垯
+     * @return 缁撴灉
      */
     @Override
-    public Result removeById(String id) {
-        if(baseMapper.deleteById(id) > 0) {
-            return Result.ok("鍒犻櫎鎴愬姛");
-        }
-        return Result.error("鍒犻櫎澶辫触");
+    public int updateCheckRule(CheckRule checkRule)
+    {
+
+        return checkRuleMapper.updateCheckRule(checkRule);
     }
 
     /**
-     * 鍒嗛〉鏌ヨ
-     * @param query
-     * @return
+     * 鎵归噺鍒犻櫎鑰冩牳瑙勫垯
+     * 
+     * @param ids 闇�瑕佸垹闄ょ殑鑰冩牳瑙勫垯涓婚敭
+     * @return 缁撴灉
      */
     @Override
-    public Result page(CheckRuleQuery query) {
-
-        IPage<CheckRule> page = new LambdaQueryChainWrapper<>(baseMapper)
-                .like(StringUtils.hasText(query.getRuleName()), CheckRule::getRuleName, query.getRuleName())
-                .between(Objects.nonNull(query.getStart()) && Objects.nonNull(query.getEnd()),
-                        CheckRule::getCreateTime,
-                        DateUtils.getDayStart(query.getStart()),
-                        DateUtils.getDayEnd(query.getEnd()))
-                .orderByDesc(CheckRule::getCreateTime)
-                .page(PageUtil.getPage(query, CheckRule.class));
-
-        List<CheckRuleVO> vos = page.getRecords().stream()
-                .map(
-                        entity -> CheckRuleVO.getVoByEntity(entity, null)
-                )
-                .collect(Collectors.toList());
-        return Result.ok().data(vos).total(page.getTotal());
+    public int deleteCheckRuleByIds(Long[] ids)
+    {
+        return checkRuleMapper.deleteCheckRuleByIds(ids);
     }
 
     /**
-     * 鏍规嵁id鏌ユ壘
-     * @param id
-     * @return
+     * 鍒犻櫎鑰冩牳瑙勫垯淇℃伅
+     * 
+     * @param id 鑰冩牳瑙勫垯涓婚敭
+     * @return 缁撴灉
      */
     @Override
-    public Result detail(String id) {
-
-        CheckRule entity = baseMapper.selectById(id);
-        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
-        CheckRuleVO vo = CheckRuleVO.getVoByEntity(entity, null);
-        return Result.ok().data(vo);
-    }
-
-    /**
-     * 鍒楄〃
-     * @return
-     */
-    @Override
-    public Result all() {
-        List<CheckRule> entities = baseMapper.selectList(null);
-        List<CheckRuleVO> vos = entities.stream()
-                .map(
-                        entity -> CheckRuleVO.getVoByEntity(entity, null)
-                )
-                .collect(Collectors.toList());
-        return Result.ok().data(vos);
+    public int deleteCheckRuleById(Long id)
+    {
+        return checkRuleMapper.deleteCheckRuleById(id);
     }
 }

--
Gitblit v1.8.0