¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.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.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.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.utils.ValidateUtil; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | 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.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class PartsInfoServiceImpl extends ServiceImpl<PartsInfoMapper, PartsInfo> implements IPartsInfoService { |
| | | @Autowired |
| | | private ProductInfoMapper productInfoMapper; |
| | | @Autowired |
| | | private ComponentInfoMapper componentInfoMapper; |
| | | @Autowired |
| | | private IPartsPermissionService partsPermissionService; |
| | | @Autowired |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Autowired |
| | | private IPartsDepartmentService partsDepartmentService; |
| | | @Autowired |
| | | private IProcessSpecVersionService processSpecVersionService; |
| | | @Autowired |
| | | private IProcessStreamService processStreamService; |
| | | @Autowired |
| | | private IWorkStepService workStepService; |
| | | @Autowired |
| | | 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) { |
| | | if(partsInfo == null) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | if(!ValidateUtil.validateString(partsInfo.getPartsName())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NAME_NONE); |
| | | if(!ValidateUtil.validateString(partsInfo.getProductId())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); |
| | | if(!ValidateUtil.validateString(partsInfo.getComponentId())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | if(!ValidateUtil.validateString(partsInfo.getPartsCode())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_CODE_NONE); |
| | | PartsInfo en = getByCode(partsInfo.getPartsCode()); |
| | | if(en != null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_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(partsInfo.getProductId()); |
| | | if(productInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); |
| | | ComponentInfo componentInfo = componentInfoMapper.selectById(partsInfo.getComponentId()); |
| | | if(componentInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | partsInfo.setPartsStatus(1); |
| | | boolean b = super.save(partsInfo); |
| | | List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(componentInfo.getComponentId(),DocAttributionTypeEnum.COMPONENT.getCode().toString(),"1"); |
| | | if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { |
| | | List<PartsDepartment> partsDepartmentList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | oldDepartPermList.forEach(item -> { |
| | | PartsDepartment pd = new PartsDepartment(); |
| | | pd.setDepartId(item.getDepartId()); |
| | | pd.setPartsId(partsInfo.getPartsId()); |
| | | partsDepartmentList.add(pd); |
| | | PermissionStreamNew perm = new PermissionStreamNew(); |
| | | perm.setDepartId(item.getDepartId()); |
| | | perm.setBusinessId(partsInfo.getPartsId()); |
| | | perm.setBusinessType(DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | permissionStreamList.add(perm); |
| | | }); |
| | | if(!partsDepartmentList.isEmpty()) { |
| | | b = partsDepartmentService.saveBatch(partsDepartmentList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productPermissionService.add(partsInfo.getPartsId(), userId,DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //æ·»å ç»ææ |
| | | ProductMix productMix = new ProductMix(Long.parseLong(partsInfo.getPartsId()),Long.parseLong(partsInfo.getComponentId()) |
| | | ,partsInfo.getPartsName(),partsInfo.getPartsCode(),DocAttributionTypeEnum.PARTS.getCode(),new Date()); |
| | | productMixService.save(productMix); |
| | | //æ·»å ç¨æ·æé |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType(DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | stream.setUserId(userId); |
| | | return permissionStreamNewService.addPermissionStreamNew(stream); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean editPartsInfo(String id, PartsInfo partsInfo) { |
| | | if(!ValidateUtil.validateString(id) || partsInfo == null) |
| | | ExceptionCast.cast(CommonCode.SUCCESS); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | if(!ValidateUtil.validateString(userId)) |
| | | ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); |
| | | PartsInfo en = super.getById(id); |
| | | if(en == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); |
| | | partsInfo.setPartsId(id); |
| | | partsInfo.setPartsStatus(null); |
| | | partsInfo.setProductId(null); |
| | | partsInfo.setComponentId(null); |
| | | boolean b = super.updateById(partsInfo); |
| | | //åæ¥ä¿®æ¹ç»ææ |
| | | ProductMix productMix = productMixService.getById(Long.parseLong(id)); |
| | | productMix.setTreeName(partsInfo.getPartsName()); |
| | | productMix.setTreeCode(partsInfo.getPartsCode()); |
| | | productMixService.updateById(productMix); |
| | | if(!b) |
| | | return false; |
| | | PartsPermission permission = partsPermissionService.getByPartsIdAndUserId(id, userId); |
| | | if(permission == null) { |
| | | permission = new PartsPermission(); |
| | | permission.setPartsId(id); |
| | | permission.setUserId(userId); |
| | | b = partsPermissionService.save(permission); |
| | | if(!b) |
| | | return false; |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId( id, userId,DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(id); |
| | | stream.setBusinessType(DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | stream.setUserId(userId); |
| | | return permissionStreamNewService.save(stream); |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | @Override |
| | | public List<PartsInfo> getByUserPerms(String userId) { |
| | | if(!ValidateUtil.validateString(userId)) |
| | | return Collections.emptyList(); |
| | | return super.getBaseMapper().getByUserPerms(userId); |
| | | } |
| | | |
| | | @Override |
| | | public List<PartsInfo> getByUserPerms(String userId, String componentId, String queryParam) { |
| | | if(!ValidateUtil.validateString(userId)) |
| | | return Collections.emptyList(); |
| | | //å»é¤æé TODO |
| | | //return super.getBaseMapper().getByUserPermsAndParams(userId, componentId, queryParam); |
| | | LambdaQueryWrapper<PartsInfo> queryWrapper = Wrappers.lambdaQuery(); |
| | | if(ValidateUtil.validateString(componentId)) { |
| | | queryWrapper.eq(PartsInfo::getComponentId, componentId); |
| | | } |
| | | if(ValidateUtil.validateString(queryParam)) { |
| | | queryWrapper.and(wrapper->wrapper.like(PartsInfo::getPartsCode, queryParam) |
| | | .or() |
| | | .like(PartsInfo::getPartsName, queryParam)); |
| | | } |
| | | queryWrapper.orderByAsc(PartsInfo::getCreateTime); |
| | | return super.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<PartsInfo> getByProductId(String productId) { |
| | | if(!ValidateUtil.validateString(productId)) |
| | | return null; |
| | | return super.lambdaQuery().eq(PartsInfo::getProductId, productId).list(); |
| | | } |
| | | |
| | | @Override |
| | | public List<PartsInfo> getByComponentId(String productId, String componentId) { |
| | | if(!ValidateUtil.validateString(productId) || !ValidateUtil.validateString(componentId)) |
| | | return null; |
| | | return super.lambdaQuery().eq(PartsInfo::getProductId, productId).eq(PartsInfo::getComponentId, componentId).list(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteCollection(List<PartsInfo> partsInfoList) { |
| | | if(partsInfoList == null || partsInfoList.isEmpty()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | partsInfoList.forEach(item -> { |
| | | boolean b = partsPermissionService.deleteByPartsId(item.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = partsDepartmentService.deleteByPartsId(item.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),DocAttributionTypeEnum.PARTS.getCode().toString(),"0"); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),DocAttributionTypeEnum.PARTS.getCode().toString(),"1"); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = super.removeById(item.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | }); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean deletePartsInfo(String partsId) { |
| | | if(!ValidateUtil.validateString(partsId)) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | PartsInfo partsInfo = super.getById(partsId); |
| | | if(partsInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); |
| | | List<ProcessSpecVersion> processSpecVersions = processSpecVersionService.getByPartsId(partsId); |
| | | if(processSpecVersions != null && !processSpecVersions.isEmpty()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST); |
| | | boolean b = partsPermissionService.deleteByPartsId(partsInfo.getPartsId()); |
| | | //éªè¯æ¯å¦åå¨ææ¡£ |
| | | List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type",DocAttributionTypeEnum.PARTS.getCode().toString()).eq("attribution_id",partsId)); |
| | | if (!docRelativeList.isEmpty()){ |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DOC_EXIST); |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = partsDepartmentService.deleteByPartsId(partsInfo.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,DocAttributionTypeEnum.PARTS.getCode().toString(),"0"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,DocAttributionTypeEnum.PARTS.getCode().toString(),"1"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productMixService.removeById(partsId); |
| | | if (!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | return super.removeById(partsId); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddUser(PartsInfo partsInfo, Collection<SysUser> userList) { |
| | | if(partsInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); |
| | | if(en == null) { |
| | | en = new PartsPermission(); |
| | | en.setUserId(item.getId()); |
| | | en.setPartsId(partsInfo.getPartsId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType(DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = partsPermissionService.saveBatch(permissionList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignRemoveUser(PartsInfo partsInfo, Collection<SysUser> userList) { |
| | | if(partsInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | //æ¸
ç©ºç¨æ·æéæ ¡éª |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = partsPermissionService.removeByCollection(permissionList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) { |
| | | if(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en == null) { |
| | | en = new PartsDepartment(); |
| | | en.setDepartId(item.getId()); |
| | | en.setPartsId(partsInfo.getPartsId()); |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType(DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!partsDepartments.isEmpty()) { |
| | | boolean b = partsDepartmentService.saveBatch(partsDepartments); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignRemoveDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) { |
| | | if(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en != null) { |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),DocAttributionTypeEnum.PARTS.getCode().toString()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!partsDepartments.isEmpty()) { |
| | | boolean b = partsDepartmentService.removeByCollection(partsDepartments); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<PartsInfo> getByComponentIdList(String productId, List<String> componentIds) { |
| | | if(!ValidateUtil.validateString(productId) || componentIds == null || componentIds.isEmpty()) |
| | | return null; |
| | | List<PartsInfo> list = new ArrayList<>(); |
| | | if(componentIds.size() > 1000){ |
| | | List<List<String>> compListArr = ListUtils.partition(componentIds, 100); |
| | | for(List<String> compList : compListArr){ |
| | | List<PartsInfo> partsList = super.lambdaQuery().eq(PartsInfo::getProductId, productId).in(PartsInfo::getComponentId, compList).list(); |
| | | if(partsList != null && !partsList.isEmpty()){ |
| | | list.addAll(partsList); |
| | | } |
| | | } |
| | | }else { |
| | | list = super.lambdaQuery().eq(PartsInfo::getProductId, productId).in(PartsInfo::getComponentId, componentIds).list(); |
| | | } |
| | | if(list == null || list.isEmpty()) |
| | | return null; |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public PartsInfo getByCode(String partsCode) { |
| | | if(ValidateUtil.validateString(partsCode)) { |
| | | List<PartsInfo> list = super.lambdaQuery().eq(PartsInfo::getPartsCode, partsCode).list(); |
| | | if(list == null || list.isEmpty()) |
| | | return null; |
| | | return list.get(0); |
| | | } |
| | | 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 (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.PARTS.getCode())){ |
| | | 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(DocAttributionTypeEnum.PARTS.getCode()); |
| | | docInfos=docInfoService.findListByDocQuery(docQuery); |
| | | } |
| | | if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.PARTS.getCode())){ |
| | | List<String> id =new ArrayList<>(); |
| | | id.add(treeInfoRequest.getAttributionId()); |
| | | treeInfoRequest.setPartsIds(id); |
| | | //å·¥èºè§ç¨çæ¬ |
| | | List<DocInfo> processSpecVersions = processSpecVersionService.getByProcessSpecVersion(treeInfoRequest); |
| | | docInfos.addAll(processSpecVersions); |
| | | //å·¥åº |
| | | List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest); |
| | | docInfos.addAll(processStreams); |
| | | //å·¥æ¥ |
| | | List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest); |
| | | docInfos.addAll(workSteps); |
| | | } |
| | | return docInfos; |
| | | } |
| | | } |