From bb696e8e702854b62b144b22e20e36981301e6cf Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期四, 17 四月 2025 09:46:24 +0800
Subject: [PATCH] 新增筛选电子样板接口、新增强制终止流程方法,

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java |   89 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
index 486ed9f..9b22567 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -1,6 +1,7 @@
 package org.jeecg.modules.dnc.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -8,31 +9,27 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.dnc.dto.ComponentExt;
-
+import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.dnc.exception.ExceptionCast;
 import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
 import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
+import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
+import org.jeecg.modules.dnc.request.TreeInfoRequest;
 import org.jeecg.modules.dnc.response.CommonCode;
 import org.jeecg.modules.dnc.response.ComponentInfoCode;
 import org.jeecg.modules.dnc.response.ProductInfoCode;
 import org.jeecg.modules.dnc.response.UcenterCode;
-
 import org.jeecg.modules.dnc.service.*;
-import org.jeecg.modules.dnc.ucenter.Department;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
-import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.dnc.entity.ComponentInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ComponentInfoSeServiceImpl extends ServiceImpl<ComponentInfoMapper, ComponentInfo> implements IComponentInfoService {
@@ -48,14 +45,18 @@
     @Lazy
     private IPartsInfoService partsInfoService;
     @Autowired
+    private IProcessSpecVersionService processSpecVersionService;
+    @Autowired
     private IProcessStreamService processStreamService;
     @Autowired
-    private IDocInfoService docInfoService;
+    private IProductMixService productMixService;
     @Autowired
     private IDocRelativeService iDocRelativeService;
     @Autowired
     private IProductPermissionService productPermissionService;
-
+    @Autowired
+    @Lazy
+    private IDocInfoService docInfoService;
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public boolean addComponentInfo(ComponentInfo componentInfo) {
@@ -125,13 +126,23 @@
         if (!b) {
             ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
         }
-        //鍘婚櫎榛樿鏂板宸ュ簭锛岃浆涓烘墜鍔ㄦ坊鍔�
+        //娣诲姞缁撴瀯鏍�
+        ProductMix productMix=null;
+        if (componentInfo.getParentId() != null) {
+            //瀛愰儴浠�
+            productMix = new ProductMix(Long.parseLong(componentInfo.getComponentId()),Long.parseLong(componentInfo.getParentId())
+                    ,componentInfo.getComponentName(),componentInfo.getComponentCode(),2,new Date());
+        }else {
+            productMix = new ProductMix(Long.parseLong(componentInfo.getComponentId()),Long.parseLong(productInfo.getProductId())
+                    ,componentInfo.getComponentName(),componentInfo.getComponentCode(),2,new Date());
+        }
+        productMixService.save(productMix);
         //娣诲姞鏉冮檺
         PermissionStreamNew stream = new PermissionStreamNew();
         stream.setUserId(userId);
         stream.setBusinessId(componentInfo.getComponentId());
         stream.setBusinessType("2");
-        return permissionStreamNewService.save(stream);
+        return permissionStreamNewService.addPermissionStreamNew(stream);
     }
 
     @Override
@@ -154,6 +165,11 @@
         componentInfo.setRankLevel(null);
         componentInfo.setProductId(null);
         boolean b = super.updateById(componentInfo);
+        //鍚屾淇敼缁撴瀯鏍�
+        ProductMix productMix = productMixService.getById(Long.parseLong(id));
+        productMix.setName(componentInfo.getComponentName());
+        productMix.setCode(componentInfo.getComponentCode());
+        productMixService.updateById(productMix);
         if(!b)
             return false;
         ComponentPermission permission = componentPermissionService.getByComponentIdAndUserId(id, userId);
@@ -277,6 +293,9 @@
             ExceptionCast.cast(CommonCode.FAIL);
         b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1");
         if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = productMixService.removeById(id);
+        if (!b)
             ExceptionCast.cast(CommonCode.FAIL);
         return super.removeById(id);
     }
@@ -505,4 +524,46 @@
         queryWrapper.orderByAsc(ComponentInfo::getCreateTime);
         return super.list(queryWrapper);
     }
+
+    /**
+     * 閫氳繃闆朵欢鍙枫�佹潗璐ㄧ瓑鏌ヨ瀵瑰簲鐢靛瓙鏍锋澘
+     * @param treeInfoRequest
+     * @return
+     */
+    @Override
+    public List<DocInfo> getByComponentInfo(TreeInfoRequest treeInfoRequest){
+        LambdaQueryWrapper<ComponentInfo> queryWrapper = new LambdaQueryWrapper<>();
+        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
+            queryWrapper.in(ComponentInfo::getProductId, treeInfoRequest.getProductIds());
+        }
+        if (treeInfoRequest.getAttributionType()==2){
+            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ComponentInfo::getComponentId,treeInfoRequest.getAttributionId());
+        }
+
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ComponentInfo::getComponentCode, treeInfoRequest.getTreeCode());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ComponentInfo::getComponentName, treeInfoRequest.getTreeName());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getStructureType()),ComponentInfo::getStructureType, treeInfoRequest.getStructureType());
+        queryWrapper.orderByDesc(ComponentInfo::getCreateTime);
+        List<ComponentInfo> list = super.list(queryWrapper);
+        List<DocInfo> docInfos = new ArrayList<>();
+        if (list != null && !list.isEmpty()) {
+            String ids=list.stream().map(ComponentInfo::getComponentId).collect(Collectors.joining(","));
+            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+            BeanUtil.copyProperties(treeInfoRequest,docQuery);
+            docQuery.setAttributionIds(ids);
+            docQuery.setDocClassCode("OTHER");
+            docQuery.setAttributionType(2);
+            docInfos=docInfoService.findListByDocQuery(docQuery);
+        }
+        if (treeInfoRequest.getAttributionType()==2){
+            List<String> id =new ArrayList<>();
+            id.add(treeInfoRequest.getAttributionId());
+            treeInfoRequest.setComponentIds(id);
+            List<DocInfo> partsInfos = partsInfoService.getByPartsInfo(treeInfoRequest);
+            docInfos.addAll(partsInfos);
+            List<DocInfo> processSpecVersions = processSpecVersionService.getByProcessSpecVersion(treeInfoRequest);
+            docInfos.addAll(processSpecVersions);
+        }
+        return docInfos;
+    }
 }

--
Gitblit v1.9.3