From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 25 六月 2025 11:51:38 +0800
Subject: [PATCH] Merge branch 'mdc_hyjs_master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentDepartmentServiceImpl.java |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentDepartmentServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentDepartmentServiceImpl.java
new file mode 100644
index 0000000..8d6d422
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentDepartmentServiceImpl.java
@@ -0,0 +1,102 @@
+package org.jeecg.modules.dnc.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.dnc.entity.ComponentDepartment;
+import org.jeecg.modules.dnc.mapper.ComponentDepartmentMapper;
+import org.jeecg.modules.dnc.service.IComponentDepartmentService;
+import org.jeecg.modules.dnc.utils.ValidateUtil;
+import org.apache.commons.collections4.ListUtils;
+import org.jeecg.modules.system.entity.MdcProduction;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class ComponentDepartmentServiceImpl extends ServiceImpl<ComponentDepartmentMapper, ComponentDepartment> implements IComponentDepartmentService {
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByComponentId(String componentId) {
+        if(!ValidateUtil.validateString(componentId))
+            return false;
+        LambdaQueryWrapper<ComponentDepartment> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.eq(ComponentDepartment::getComponentId, componentId);
+        return super.remove(lambdaQueryWrapper);
+    }
+
+    @Override
+    public List<MdcProduction> getDepartPermsByComponentId(String componentId) {
+        return super.getBaseMapper().getDepartPermsByComponentId(componentId);
+    }
+
+    @Override
+    public List<MdcProduction> getDepartNonPermsByComponentId(String componentId) {
+        return super.getBaseMapper().getDepartNonPermsByComponentId(componentId);
+    }
+
+    @Override
+    public ComponentDepartment getByComponentIdAndDepartId(String componentId, String departId) {
+        if(!ValidateUtil.validateString(componentId) || !ValidateUtil.validateString(departId))
+            return null;
+        List<ComponentDepartment> list = super.lambdaQuery().eq(ComponentDepartment::getComponentId, componentId).eq(ComponentDepartment::getDepartId, departId).list();
+        if(list == null || list.isEmpty())
+            return null;
+        return list.get(0);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean removeByCollection(List<ComponentDepartment> componentDepartments) {
+        if(componentDepartments == null || componentDepartments.isEmpty())
+            return false;
+        if(componentDepartments.size() == 1) {
+            return super.removeById(componentDepartments.get(0).getComponentDepartId());
+        }
+        List<String> ids = new ArrayList<>();
+        componentDepartments.forEach(item -> {
+            ids.add(item.getComponentDepartId());
+        });
+        if(ids.size() > 1000){
+            List<List<String>> idsArr = ListUtils.partition(ids, 1000);
+            for(List<String> arr : idsArr){
+                super.removeByIds(arr);
+            }
+            return true;
+        }else {
+            return super.removeByIds(ids);
+        }
+    }
+
+    @Override
+    public List<ComponentDepartment> getByComponentIdsAndDepartIds(List<String> componentIds, List<String> departIds) {
+        if(componentIds == null || componentIds.isEmpty() || departIds == null || departIds.isEmpty())
+            return null;
+        List<ComponentDepartment> total = new ArrayList<>();
+        List<List<String>> compListArr;
+        List<List<String>> departListArr;
+        if(componentIds.size() > 1000){
+            compListArr = ListUtils.partition(componentIds, 100);
+        }else {
+            compListArr = ListUtils.partition(componentIds, 1000);
+        }
+        if(departIds.size() > 1000){
+            departListArr = ListUtils.partition(departIds, 100);
+        }else {
+            departListArr = ListUtils.partition(departIds, 1000);
+        }
+        for(List<String> compList : compListArr) {
+            for(List<String> departList : departListArr){
+                LambdaQueryWrapper<ComponentDepartment> queryWrapper = Wrappers.lambdaQuery();
+                queryWrapper.in(ComponentDepartment::getComponentId, compList);
+                queryWrapper.in(ComponentDepartment::getDepartId, departList);
+                List<ComponentDepartment> list = super.list(queryWrapper);
+                if(list != null && !list.isEmpty()){
+                    total.addAll(list);
+                }
+            }
+        }
+        return total;
+    }
+}

--
Gitblit v1.9.3