From 2fb6c67b2c0c72195eef6fe5f7904d739b46e2c0 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:57:28 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java | 169 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 127 insertions(+), 42 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java index bec7eda..3df5489 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java @@ -1,17 +1,22 @@ package org.jeecg.modules.dnc.service.impl; +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.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; 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.ProcessSpecVersionMapper; 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.utils.ValidateUtil; @@ -21,10 +26,8 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -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 ProcessSpecVersionServiceImpl extends ServiceImpl<ProcessSpecVersionMapper, ProcessSpecVersion> implements IProcessSpecVersionService{ @@ -33,7 +36,7 @@ @Autowired private ComponentInfoMapper componentInfoMapper; @Autowired - private PartsInfoMapper processSpecVersionMapper; + private PartsInfoMapper partsInfoMapper; @Autowired private IPermissionStreamNewService permissionStreamNewService; @Autowired @@ -49,6 +52,9 @@ private IWorkStepService workStepService; @Autowired private IProductPermissionService productPermissionService; + @Autowired + @Lazy + private IDocInfoService docInfoService; /** * 鏍规嵁鐢ㄦ埛id鑾峰彇鎺堟潈鐨勫伐鑹鸿绋嬬増鏈〃淇℃伅 * @param userId @@ -85,56 +91,65 @@ /** * 鏂板宸ヨ壓瑙勭▼鐗堟湰琛ㄤ俊鎭� - * @param ProcessSpecVersion + * @param processSpecVersion * @return */ @Override - public boolean addProcessSpecVersion(ProcessSpecVersion ProcessSpecVersion){ - if(ProcessSpecVersion == null) + public boolean addProcessSpecVersion(ProcessSpecVersion processSpecVersion){ + if(processSpecVersion == null) ExceptionCast.cast(CommonCode.INVALID_PARAM); - if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionName())) - ExceptionCast.cast(PartsInfoCode.PARTS_NAME_NONE); - if(!ValidateUtil.validateString(ProcessSpecVersion.getProductId())) + if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionName())) + ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE); + if(!ValidateUtil.validateString(processSpecVersion.getProductId())) ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); - if(!ValidateUtil.validateString(ProcessSpecVersion.getComponentId())) + if(!ValidateUtil.validateString(processSpecVersion.getComponentId())) ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); - if(!ValidateUtil.validateString(ProcessSpecVersion.getPartsId())) + if(!ValidateUtil.validateString(processSpecVersion.getPartsId())) ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE); - if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionCode())) + if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionCode())) ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE); - ProcessSpecVersion en = getByCode(ProcessSpecVersion.getProcessSpecVersionCode()); + ProcessSpecVersion en = getByCode(processSpecVersion.getPartsId(),processSpecVersion.getProcessSpecVersionCode()); if(en != null) ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); if(!ValidateUtil.validateString(userId)) ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); - ProductInfo productInfo = productInfoMapper.selectById(ProcessSpecVersion.getProductId()); + ProductInfo productInfo = productInfoMapper.selectById(processSpecVersion.getProductId()); if(productInfo == null) ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); - ComponentInfo componentInfo = componentInfoMapper.selectById(ProcessSpecVersion.getComponentId()); + ComponentInfo componentInfo = componentInfoMapper.selectById(processSpecVersion.getComponentId()); if(componentInfo == null) ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); - PartsInfo processSpecVersion = processSpecVersionMapper.selectById(ProcessSpecVersion.getPartsId()); - if(processSpecVersion == null) + PartsInfo partsInfo = partsInfoMapper.selectById(processSpecVersion.getPartsId()); + if(partsInfo == null) ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); - boolean b = super.save(ProcessSpecVersion); + //鐩稿悓闆朵欢鍙蜂笅闈㈢増鏈彿涓嶈兘閲嶅 + List<ProcessSpecVersion> list = super.list(new LambdaQueryWrapper<ProcessSpecVersion>().eq(ProcessSpecVersion::getPartsId,partsInfo.getPartsId())); + if (list != null && list.size() > 0) { + list.forEach(processSpecVersion1 -> { + if (processSpecVersion1.getProcessSpecVersionCode().equals(processSpecVersion.getProcessSpecVersionCode())) { + ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST); + } + }); + } + boolean b = super.save(processSpecVersion); if(!b) ExceptionCast.cast(CommonCode.FAIL); //娣诲姞閮ㄩ棬鏉冮檺 - List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(ProcessSpecVersion.getPartsId(),"3","1"); + List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(processSpecVersion.getPartsId(), DocAttributionTypeEnum.PARTS.getCode().toString(),"1"); if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { List<ProcessSpecVersionDepartment> processSpecVersionDepartmentList = new ArrayList<>(); List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); oldDepartPermList.forEach(item -> { ProcessSpecVersionDepartment pd = new ProcessSpecVersionDepartment(); pd.setDepartId(item.getDepartId()); - pd.setPsvId(ProcessSpecVersion.getId()); + pd.setPsvId(processSpecVersion.getId()); processSpecVersionDepartmentList.add(pd); PermissionStreamNew perm = new PermissionStreamNew(); perm.setDepartId(item.getDepartId()); - perm.setBusinessId(ProcessSpecVersion.getId()); - perm.setBusinessType("4"); + perm.setBusinessId(processSpecVersion.getId()); + perm.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); permissionStreamList.add(perm); }); if(!processSpecVersionDepartmentList.isEmpty()) { @@ -149,20 +164,21 @@ } } //娣诲姞鐢ㄦ埛鏉冮檺 - b = productPermissionService.add(ProcessSpecVersion.getId(), userId,"4"); + b = productPermissionService.add(processSpecVersion.getId(), userId,DocAttributionTypeEnum.OPERATION.getCode().toString()); if (!b) { ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); } //娣诲姞缁撴瀯鏍� - ProductMix productMix = new ProductMix(Long.parseLong(ProcessSpecVersion.getId()),Long.parseLong(ProcessSpecVersion.getPartsId()) - ,ProcessSpecVersion.getProcessSpecVersionName(),ProcessSpecVersion.getProcessSpecVersionCode(),4); + ProductMix productMix = new ProductMix(Long.parseLong(processSpecVersion.getId()),Long.parseLong(processSpecVersion.getPartsId()) + ,processSpecVersion.getProcessSpecVersionName(), + processSpecVersion.getProcessSpecVersionCode(),DocAttributionTypeEnum.OPERATION.getCode(),new Date()); productMixService.save(productMix); //娣诲姞鐢ㄦ埛鏉冮檺 PermissionStreamNew stream = new PermissionStreamNew(); - stream.setBusinessId(ProcessSpecVersion.getId()); - stream.setBusinessType("4"); + stream.setBusinessId(processSpecVersion.getId()); + stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); stream.setUserId(userId); - return permissionStreamNewService.save(stream); + return permissionStreamNewService.addPermissionStreamNew(stream); } /** @@ -189,8 +205,8 @@ boolean b = super.updateById(processSpecVersion); //鍚屾淇敼缁撴瀯鏍� ProductMix productMix = productMixService.getById(Long.parseLong(id)); - productMix.setName(processSpecVersion.getProcessSpecVersionName()); - productMix.setCode(processSpecVersion.getProcessSpecVersionCode()); + productMix.setTreeName(processSpecVersion.getProcessSpecVersionName()); + productMix.setTreeCode(processSpecVersion.getProcessSpecVersionCode()); productMixService.updateById(productMix); if(!b) return false; @@ -201,7 +217,7 @@ if(!b) return false; } - PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,"4"); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,DocAttributionTypeEnum.OPERATION.getCode().toString()); if(stream == null) { stream = new PermissionStreamNew(); stream.setBusinessId(id); @@ -232,10 +248,10 @@ b = processSpecVersionDepartmentService.deleteByPsvId(processSpecVersion.getId()); if(!b) ExceptionCast.cast(CommonCode.FAIL); - b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","0"); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"0"); if(!b) ExceptionCast.cast(CommonCode.FAIL); - b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","1"); + b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"1"); if(!b) ExceptionCast.cast(CommonCode.FAIL); b = productMixService.removeById(processSpecVersion.getId()); @@ -245,9 +261,11 @@ } @Override - public ProcessSpecVersion getByCode(String processSpecVersionCode) { + public ProcessSpecVersion getByCode(String partId,String processSpecVersionCode) { if(ValidateUtil.validateString(processSpecVersionCode)) { - List<ProcessSpecVersion> list = super.lambdaQuery().eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list(); + List<ProcessSpecVersion> list = super.lambdaQuery() + .eq(ProcessSpecVersion::getPartsId, partId) + .eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list(); if(list == null || list.isEmpty()) return null; return list.get(0); @@ -303,12 +321,12 @@ en.setPsvId(processSpecVersion.getId()); permissionList.add(en); } - PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4"); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); if(stream == null) { stream = new PermissionStreamNew(); stream.setUserId(item.getId()); stream.setBusinessId(processSpecVersion.getId()); - stream.setBusinessType("4"); + stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); permissionStreamList.add(stream); } }); @@ -345,7 +363,7 @@ if(en != null) { permissionList.add(en); } - PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4"); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); if(stream != null) { permissionStreamList.add(stream); } @@ -385,12 +403,12 @@ en.setPsvId(processSpecVersion.getId()); partsDepartments.add(en); } - PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),"4"); + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); if(stream == null) { stream = new PermissionStreamNew(); stream.setDepartId(item.getId()); stream.setBusinessId(processSpecVersion.getId()); - stream.setBusinessType("4"); + stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); permissionStreamList.add(stream); } }); @@ -457,4 +475,71 @@ List<WorkStep> workStepList=workStepService.list(new LambdaQueryWrapper<WorkStep>().eq(WorkStep::getPsvId,processSpecId)); return null; } + + /** + * 閫氳繃闆朵欢鍙枫�佹潗璐ㄧ瓑鏌ヨ瀵瑰簲鐢靛瓙鏍锋澘 + * @param treeInfoRequest + * @return + */ + @Override + public List<DocInfo> getByProcessSpecVersion(TreeInfoRequest treeInfoRequest){ + LambdaQueryWrapper<ProcessSpecVersion> queryWrapper = new LambdaQueryWrapper<>(); + if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) { + queryWrapper.in(ProcessSpecVersion::getProductId, treeInfoRequest.getProductIds()); + } + if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) { + queryWrapper.in(ProcessSpecVersion::getComponentId, treeInfoRequest.getComponentIds()); + } + if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) { + queryWrapper.in(ProcessSpecVersion::getPartsId, treeInfoRequest.getPartsIds()); + } + if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){ + queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ProcessSpecVersion::getId,treeInfoRequest.getAttributionId()); + } + queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ProcessSpecVersion::getProcessSpecVersionName, treeInfoRequest.getTreeName()); + queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName()); + queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime); + List<ProcessSpecVersion> list = super.list(queryWrapper); + List<DocInfo> docInfos; + if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){ + return new ArrayList<>(); + }else { + String ids=list.stream().map(ProcessSpecVersion::getId).collect(Collectors.joining(",")); + DocInfoQueryRequest docQuery = new DocInfoQueryRequest(); + BeanUtil.copyProperties(treeInfoRequest,docQuery); + docQuery.setAttributionIds(ids); + docQuery.setDocClassCode("OTHER"); + docQuery.setAttributionType(DocAttributionTypeEnum.OPERATION.getCode()); + docInfos=docInfoService.findListByDocQuery(docQuery); + if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){ + List<String> id =new ArrayList<>(); + id.add(treeInfoRequest.getAttributionId()); + treeInfoRequest.setPsvIds(id); + //宸ュ簭 + List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest); + docInfos.addAll(processStreams); + //宸ユ + List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest); + docInfos.addAll(workSteps); + } + } + return docInfos; + } + + @Override + public boolean assignPermission(Object entity, Collection<SysUser> userList, boolean isAdd){ + if (isAdd) { + return assignAddUser((ProcessSpecVersion) entity, userList); + } else { + return assignRemoveUser((ProcessSpecVersion) entity, userList); + } + } + @Override + public boolean assignDepartPermission(Object entity, Collection<MdcProduction> departments, boolean isAdd) { + if (isAdd) { + return assignAddDepart((ProcessSpecVersion) entity, departments); + } else { + return assignRemoveDepart((ProcessSpecVersion) entity, departments); + } + } } -- Gitblit v1.9.3