From 1cbbb341d22e3c46b15af65b6f97d738bae7ca95 Mon Sep 17 00:00:00 2001
From: yangbin <yangbin>
Date: 星期二, 20 五月 2025 10:46:57 +0800
Subject: [PATCH] 自动化

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

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
index b5d9480..33580e8 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
@@ -1,40 +1,36 @@
 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;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.collections4.ListUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-
+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.PartsInfoMapper;
 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.PartsInfoCode;
 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.apache.commons.collections4.ListUtils;
-
 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 PartsInfoServiceImpl extends ServiceImpl<PartsInfoMapper, PartsInfo> implements IPartsInfoService {
@@ -54,6 +50,11 @@
     private IDocRelativeService iDocRelativeService;
     @Autowired
     private IProductPermissionService productPermissionService;
+    @Autowired
+    private IProductMixService productMixService;
+    @Autowired
+    @Lazy
+    private IDocInfoService docInfoService;
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public boolean addPartsInfo(PartsInfo partsInfo) {
@@ -114,12 +115,16 @@
         if (!b) {
             ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
         }
+        //娣诲姞缁撴瀯鏍�
+        ProductMix productMix = new ProductMix(Long.parseLong(partsInfo.getPartsId()),Long.parseLong(partsInfo.getComponentId())
+                ,partsInfo.getPartsName(),partsInfo.getPartsCode(),3,new Date());
+        productMixService.save(productMix);
         //娣诲姞鐢ㄦ埛鏉冮檺
         PermissionStreamNew stream = new PermissionStreamNew();
         stream.setBusinessId(partsInfo.getPartsId());
         stream.setBusinessType("3");
         stream.setUserId(userId);
-        return permissionStreamNewService.save(stream);
+        return permissionStreamNewService.addPermissionStreamNew(stream);
     }
 
     @Override
@@ -139,6 +144,11 @@
         partsInfo.setProductId(null);
         partsInfo.setComponentId(null);
         boolean b = super.updateById(partsInfo);
+        //鍚屾淇敼缁撴瀯鏍�
+        ProductMix productMix = productMixService.getById(Long.parseLong(id));
+        productMix.setName(partsInfo.getPartsName());
+        productMix.setCode(partsInfo.getPartsCode());
+        productMixService.updateById(productMix);
         if(!b)
             return false;
         PartsPermission permission = partsPermissionService.getByPartsIdAndUserId(id, userId);
@@ -253,7 +263,10 @@
         b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,"3","1");
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        return super.removeById(partsInfo.getPartsId());
+        b = productMixService.removeById(partsId);
+        if (!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        return super.removeById(partsId);
     }
 
     @Override
@@ -431,4 +444,45 @@
         return null;
     }
 
+    /**
+     * 閫氳繃闆朵欢鍙枫�佹潗璐ㄧ瓑鏌ヨ瀵瑰簲鐢靛瓙鏍锋澘
+     * @param treeInfoRequest
+     * @return
+     */
+    @Override
+    public List<DocInfo> getByPartsInfo(TreeInfoRequest treeInfoRequest){
+        LambdaQueryWrapper<PartsInfo> queryWrapper = new LambdaQueryWrapper<>();
+        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
+            queryWrapper.in(PartsInfo::getProductId, treeInfoRequest.getProductIds());
+        }
+        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
+            queryWrapper.in(PartsInfo::getComponentId, treeInfoRequest.getComponentIds());
+        }
+        if (treeInfoRequest.getAttributionType()==3){
+            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),PartsInfo::getPartsId,treeInfoRequest.getAttributionId());
+        }
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),PartsInfo::getPartsCode, treeInfoRequest.getTreeCode());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),PartsInfo::getPartsName, treeInfoRequest.getTreeName());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getStructureType()),PartsInfo::getStructureType, treeInfoRequest.getStructureType());
+        queryWrapper.orderByDesc(PartsInfo::getCreateTime);
+        List<PartsInfo> list = super.list(queryWrapper);
+        List<DocInfo> docInfos = new ArrayList<>();
+        if (list != null && !list.isEmpty()) {
+            String ids=list.stream().map(PartsInfo::getPartsId).collect(Collectors.joining(","));
+            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+            BeanUtil.copyProperties(treeInfoRequest,docQuery);
+            docQuery.setAttributionIds(ids);
+            docQuery.setDocClassCode("OTHER");
+            docQuery.setAttributionType(3);
+            docInfos=docInfoService.findListByDocQuery(docQuery);
+        }
+        if (treeInfoRequest.getAttributionType()==3){
+            List<String> id =new ArrayList<>();
+            id.add(treeInfoRequest.getAttributionIds());
+            treeInfoRequest.setPartsIds(id);
+            List<DocInfo> processSpecVersions = processSpecVersionService.getByProcessSpecVersion(treeInfoRequest);
+            docInfos.addAll(processSpecVersions);
+        }
+        return docInfos;
+    }
 }

--
Gitblit v1.9.3