From c6eb2d4ecd99bee148892abfbdca3e42f3dd6084 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期三, 07 五月 2025 18:08:07 +0800
Subject: [PATCH] 工具管理-仓库管理功能
---
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java | 198 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 183 insertions(+), 15 deletions(-)
diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
index 9a775e3..d289e58 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
@@ -1,16 +1,22 @@
package org.jeecg.modules.dnc.service.impl;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
+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 lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
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.ProductInfoMapper;
+import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
+import org.jeecg.modules.dnc.request.TreeInfoRequest;
import org.jeecg.modules.dnc.response.*;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.dnc.service.support.ProductTreeWrapper;
@@ -78,6 +84,9 @@
private IWorkStepPermissionService iWorkStepPermissionService;
@Autowired
private IProductMixService productMixService;
+ @Autowired
+ @Lazy
+ private IDocInfoService docInfoService;
@Override
@Transactional(rollbackFor = {Exception.class})
@@ -106,14 +115,31 @@
ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
}
//娣诲姞缁撴瀯鏍�
- ProductMix productMix = new ProductMix(Long.parseLong(productInfo.getProductId()),0,productInfo.getProductName(),productInfo.getProductNo(),"1");
+ ProductMix productMix = new ProductMix(Long.parseLong(productInfo.getProductId()),0L,
+ productInfo.getProductName(),productInfo.getProductNo(),1,new Date());
productMixService.save(productMix);
+ //娣诲姞鐢ㄦ埛閮ㄩ棬
+ if(StrUtil.isNotBlank(user.getProductionIds())){
+ String[] split = user.getProductionIds().split(",");
+ String[] departIds = split;
+ for (String departId : departIds) {
+ ProductDepartment productDepartment = new ProductDepartment();
+ productDepartment.setProductId(productInfo.getProductId());
+ productDepartment.setDepartId(departId);
+ productDepartmentService.save(productDepartment);
+ PermissionStreamNew stream = new PermissionStreamNew();
+ stream.setBusinessId(productInfo.getProductId());
+ stream.setDepartId(departId);
+ stream.setBusinessType("1");
+ permissionStreamNewService.save(stream);
+ }
+ }
//娣诲姞鐢ㄦ埛鏉冮檺
PermissionStreamNew stream = new PermissionStreamNew();
stream.setBusinessId(productInfo.getProductId());
stream.setUserId(userId);
stream.setBusinessType("1");
- return permissionStreamNewService.save(stream);
+ return permissionStreamNewService.addPermissionStreamNew(stream);
}
@Override
@@ -131,6 +157,11 @@
productInfo.setProductId(id);
productInfo.setProductStatus(null);
boolean b = super.updateById(productInfo);
+ //鍚屾淇敼缁撴瀯鏍�
+ ProductMix productMix = productMixService.getById(Long.parseLong(id));
+ productMix.setName(productInfo.getProductName());
+ productMix.setCode(productInfo.getProductNo());
+ productMixService.updateById(productMix);
if (!b)
return false;
ProductPermission permission = productPermissionService.getByProductIdAndUserId(id, userId);
@@ -946,6 +977,134 @@
return false;
}
+ @Override
+ public Result<?> getTreeById(String id, Integer type){
+ if (StrUtil.isNotEmpty(id)||type!=null){
+ switch (type){
+ case 1:
+ //浜у搧
+ QueryWrapper<ProductInfo> productInfoQueryWrapper = new QueryWrapper<>();
+ productInfoQueryWrapper.eq("product_id",id);
+ List<ProductInfo> productInfos = this.list(productInfoQueryWrapper);
+ return Result.OK(productInfos);
+ case 2:
+ //缁勪欢
+ QueryWrapper<ComponentInfo> componentInfoQueryWrapper = new QueryWrapper<>();
+ componentInfoQueryWrapper.eq("component_id",id);
+ List<ComponentInfo> componentInfos = componentInfoService.list(componentInfoQueryWrapper);
+ return Result.OK(componentInfos);
+ case 3:
+ //闆朵欢
+ QueryWrapper<PartsInfo> partsInfoQueryWrapper = new QueryWrapper<>();
+ partsInfoQueryWrapper.eq("parts_id",id);
+ List<PartsInfo> partsInfos = partsInfoService.list(partsInfoQueryWrapper);
+ return Result.OK(partsInfos);
+ case 4:
+ //宸ヨ壓瑙勫垝鐗堟湰
+ QueryWrapper<ProcessSpecVersion> processSpecVersionQueryWrapper = new QueryWrapper<>();
+ processSpecVersionQueryWrapper.eq("id",id);
+ List<ProcessSpecVersion> processSpecVersions = processSpecVersionService.list(processSpecVersionQueryWrapper);
+ return Result.OK(processSpecVersions);
+ case 5:
+ //宸ュ簭
+ QueryWrapper<ProcessStream> processStreamQueryWrapper = new QueryWrapper<>();
+ processStreamQueryWrapper.eq("process_id",id);
+ List<ProcessStream> processStreams = processStreamService.list(processStreamQueryWrapper);
+ return Result.OK(processStreams);
+ case 6:
+ //宸ユ
+ QueryWrapper<WorkStep> workStepQueryWrapper = new QueryWrapper<>();
+ workStepQueryWrapper.eq("id",id);
+ List<WorkStep> workSteps = workStepService.list(workStepQueryWrapper);
+ return Result.OK(workSteps);
+ }
+ }
+ return Result.error("鍙傛暟閿欒");
+ }
+
+ /**
+ * 閫氳繃浠e彿銆佸悕绉般�佹潗璐ㄧ瓑鏌ヨ瀵瑰簲鐢靛瓙鏍锋澘
+ * @param treeInfoRequest
+ * @return
+ */
+ @Override
+ public List<DocInfo> getByTreeOtherFileInfo(TreeInfoRequest treeInfoRequest){
+ switch (treeInfoRequest.getAttributionType()){
+ case 1:
+ LambdaQueryWrapper<ProductInfo> queryWrapper = new LambdaQueryWrapper<>();
+ // 鏄庣‘鏉′欢锛氫粎褰揳ttributionType涓�1涓攁ttributionId闈炵┖鏃舵坊鍔犳潯浠�
+ if (treeInfoRequest.getAttributionType() == 1 && StrUtil.isNotBlank(treeInfoRequest.getAttributionId())) {
+ queryWrapper.eq(ProductInfo::getProductId, treeInfoRequest.getAttributionId());
+ }
+ // 绠�鍖栨潯浠跺垽鏂�
+ queryWrapper.like(StrUtil.isNotBlank(treeInfoRequest.getTreeCode()), ProductInfo::getProductNo, treeInfoRequest.getTreeCode())
+ .like(StrUtil.isNotBlank(treeInfoRequest.getTreeName()), ProductInfo::getProductName, treeInfoRequest.getTreeName());
+ List<ProductInfo> productInfoList = super.list(queryWrapper);
+ List<DocInfo> docInfos = new ArrayList<>();
+ if (StrUtil.isNotBlank(treeInfoRequest.getStructureType())){
+ productInfoList=new ArrayList<>();
+ }
+ if (CollectionUtil.isNotEmpty(productInfoList)) {
+ // 浣跨敤ID鍒楄〃鑰岄潪鎷兼帴瀛楃涓�
+ List<String> productIds = productInfoList.stream()
+ .map(ProductInfo::getProductId)
+ .collect(Collectors.toList());
+ DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+ BeanUtil.copyProperties(treeInfoRequest, docQuery);
+ docQuery.setAttributionIds(productIds.toString()); // 鍋囪setAttributionIds鎺ュ彈List<String>
+ docQuery.setDocClassCode("OTHER");
+ docQuery.setAttributionType(1);
+ docInfos = docInfoService.findListByDocQuery(docQuery);
+ }
+ // 鍒涘缓鏂拌姹傚璞¢伩鍏嶆薄鏌撳師鍙傛暟
+ TreeInfoRequest componentRequest = new TreeInfoRequest();
+ BeanUtil.copyProperties(treeInfoRequest, componentRequest);
+ componentRequest.setProductIds(Collections.singletonList(treeInfoRequest.getAttributionId()));
+ // 鍚堝苟鏌ヨ缁撴灉
+ docInfos.addAll(componentInfoService.getByComponentInfo(componentRequest));
+ docInfos.addAll(partsInfoService.getByPartsInfo(componentRequest));
+ docInfos.addAll(processSpecVersionService.getByProcessSpecVersion(componentRequest));
+ return getByTreeOtherFileInfo(docInfos);
+ case 2:
+ return getByTreeOtherFileInfo(componentInfoService.getByComponentInfo(treeInfoRequest));
+ case 3:
+ return getByTreeOtherFileInfo(partsInfoService.getByPartsInfo(treeInfoRequest));
+ case 4:
+ return getByTreeOtherFileInfo(processSpecVersionService.getByProcessSpecVersion(treeInfoRequest));
+ }
+ return new ArrayList<>();
+ }
+
+ private List<DocInfo> getByTreeOtherFileInfo(List<DocInfo> docInfos){
+ //瀵规墍灞瀒d杩涜缈昏瘧
+ if (docInfos != null && !docInfos.isEmpty()) {
+ docInfos.forEach(docInfo -> {
+ switch (docInfo.getAttributionType()){
+ case 1:
+ ProductInfo productInfo=this.getById(docInfo.getAttributionId());
+ docInfo.setNodeName(productInfo.getProductName());
+ docInfo.setNodeCode(productInfo.getProductNo());
+ break;
+ case 2:
+ ComponentInfo componentInfo=componentInfoService.getById(docInfo.getAttributionId());
+ docInfo.setNodeName(componentInfo.getComponentName());
+ docInfo.setNodeCode(componentInfo.getComponentCode());
+ break;
+ case 3:
+ PartsInfo partsInfo=partsInfoService.getById(docInfo.getAttributionId());
+ docInfo.setNodeCode(partsInfo.getPartsCode());
+ docInfo.setNodeName(partsInfo.getPartsName());
+ break;
+ case 4:
+ ProcessSpecVersion processSpecVersion=processSpecVersionService.getById(docInfo.getAttributionId());
+ docInfo.setNodeName(processSpecVersion.getProcessSpecVersionName());
+ docInfo.setNodeCode(processSpecVersion.getProcessSpecVersionCode());
+ }
+ });
+ }
+ return docInfos;
+ }
+
/**
* 楠岃瘉杈撳叆鍙傛暟
*/
@@ -997,8 +1156,11 @@
.map(PartsInfo::getPartsId)
.collect(Collectors.toList());
handlePartsPermissions(partsIds, userList, partsPermissionList, permissionStreamList);
- List<String> psvIds = processSpecVersionService.getByPartsIds(partsIds).stream().map(ProcessSpecVersion::getId).collect(Collectors.toList());
- handlePsvPermissions(psvIds, userList, processSpecVersionPermissionList, permissionStreamList);
+ List<ProcessSpecVersion> processSpecVersionList = processSpecVersionService.getByPartsIds(partsIds);
+ if (processSpecVersionList!= null &&!processSpecVersionList.isEmpty()) {
+ List<String> psvIds = processSpecVersionList.stream().map(ProcessSpecVersion::getId).collect(Collectors.toList());
+ handlePsvPermissions(psvIds, userList, processSpecVersionPermissionList, permissionStreamList);
+ }
List<ProcessStream> processStreamList = processStreamService.getByComponentIdList(productId, componentIds, partsIds);
processStreamApi(productId, userList, processionPermissionList, workStepPermissionList, permissionStreamList, processStreamList);
}
@@ -1093,8 +1255,8 @@
componentPermissionList.add(cp);
ComponentInfo cpInfo = componentInfoMap.get(cp.getComponentId());
PermissionStreamNew s = new PermissionStreamNew();
- s.setBusinessId(cpInfo.getProductId());
- s.setBusinessType("1");
+ s.setBusinessId(cpInfo.getComponentId());
+ s.setBusinessType("2");
s.setUserId(cp.getUserId());
permissionStreamList.add(s);
}
@@ -1394,6 +1556,8 @@
.collect(Collectors.toList());
}
componentIds.add(componentInfo.getComponentId());
+
+
handleRelativePermissions(componentInfo.getProductId(), componentIds, null, null,null, userList);
}
}else {
@@ -2067,18 +2231,22 @@
private void handlePartsRemovals(String productId, List<String> componentIds,Collection<SysUser> userList) {
List<PartsInfo> partsInfoList = partsInfoService.getByComponentIdList(productId, componentIds);
- partsInfoList.forEach(item->{
- partsInfoService.assignRemoveUser(item,userList);
- //鍒犻櫎
- handlePartRelatedRemovals(item, userList);
- });
+ if (partsInfoList!=null){
+ partsInfoList.forEach(item->{
+ partsInfoService.assignRemoveUser(item,userList);
+ //鍒犻櫎
+ handlePartRelatedRemovals(item, userList);
+ });
+ }
}
private void handlePartsDepartmentRemovals(String productId, List<String> componentIds, Collection<MdcProduction> mdcProductionList) {
List<PartsInfo> partsInfoList = partsInfoService.getByComponentIdList(productId, componentIds);
- partsInfoList.forEach(item->{
- partsInfoService.assignRemoveDepart(item,mdcProductionList);
- handlePartRelatedDepartmentRemovals(item, mdcProductionList);
- });
+ if (partsInfoList!=null) {
+ partsInfoList.forEach(item->{
+ partsInfoService.assignRemoveDepart(item,mdcProductionList);
+ handlePartRelatedDepartmentRemovals(item, mdcProductionList);
+ });
+ }
}
private void handleComponentRelatedRemovals(ComponentInfo componentInfo, Collection<SysUser> userList, Collection<MdcProduction> mdcProductionList) {
--
Gitblit v1.9.3