| | |
| | | package com.qianwen.smartman.modules.cps.service.impl; |
| | | |
| | | import com.alibaba.excel.write.merge.AbstractMergeStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.CommonGroupConstant; |
| | | import com.qianwen.smartman.common.constant.ExcelConstant; |
| | | import com.qianwen.smartman.common.enums.CommonGroupTypeEnum; |
| | | import com.qianwen.smartman.common.utils.ExtraLambdaQueryWrapper; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.common.utils.ValidatorUtils; |
| | | 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 org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.alibaba.excel.write.merge.AbstractMergeStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.qianwen.core.excel.util.ExcelUtil; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.mp.support.Condition; |
| | |
| | | import com.qianwen.core.tool.node.ForestNodeMerger; |
| | | import com.qianwen.core.tool.utils.CollectionUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.CommonGroupConstant; |
| | | import com.qianwen.smartman.common.constant.ExcelConstant; |
| | | import com.qianwen.smartman.common.enums.CommonGroupTypeEnum; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.common.utils.ValidatorUtils; |
| | | import com.qianwen.smartman.modules.cps.convert.CommonGroupConvert; |
| | | import com.qianwen.smartman.modules.cps.entity.CommonGroup; |
| | | import com.qianwen.smartman.modules.cps.entity.CommonGroupOfItem; |
| | |
| | | import com.qianwen.smartman.modules.system.entity.ParamBiz; |
| | | import com.qianwen.smartman.modules.system.service.IDictService; |
| | | import com.qianwen.smartman.modules.system.service.IParamBizService; |
| | | 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 org.springframework.web.multipart.MultipartFile; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/service/impl/CommonGroupServiceImpl.class */ |
| | | public class CommonGroupServiceImpl extends ServiceImpl<CommonGroupMapper, CommonGroup> implements ICommonGroupService { |
| | | private static final String PARENT_ID = "parentId"; |
| | | private static final String ROOT_NODE_CONFIGURE_ERROR = "The root node is not configured or configured incorrectly"; |
| | |
| | | private WorkstationMapper workstationMapper; |
| | | |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public Boolean changeStatus(List<Long> ids, Integer status) { |
| | | return update(Wrappers.<CommonGroup>lambdaUpdate() |
| | | .set(CommonGroup::getStatus, status) |
| | | .in(CommonGroup::getId, ids)); |
| | | /* |
| | | return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().set((v0) -> { |
| | | return v0.getStatus(); |
| | | }, status)).in((v0) -> { |
| | | return v0.getId(); |
| | | }, ids)));*/ |
| | | |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroup> getAllSubGroup(Long id, String groupType, Integer groupCategory) { |
| | | return this.baseMapper.getAllSubGroup(id, groupType, groupCategory); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroupVO> lazyList(Long parentId, String groupType, Integer groupCategory, Map<String, Object> param) { |
| | | if (Func.isEmpty(param.get(PARENT_ID)) && param.size() == 1) { |
| | | parentId = BladeConstant.TOP_PARENT_ID; |
| | |
| | | return this.baseMapper.lazyList(AuthUtil.getTenantId(), parentId, groupType, groupCategory, param); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroupVO> tree(String tenantId, String groupType, Integer groupCategory) { |
| | | return ForestNodeMerger.merge(this.baseMapper.tree(tenantId, groupType, groupCategory)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroupVO> lazyTree(String tenantId, Long parentId) { |
| | | if (AuthUtil.isAdministrator()) { |
| | | tenantId = ""; |
| | |
| | | return ForestNodeMerger.merge(this.baseMapper.lazyTree(tenantId, parentId)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public String getGroupIds(String tenantId, String groupNames, String groupType, Integer groupCategory) { |
| | | List<CommonGroup> commonList = this.baseMapper.selectList( |
| | | Wrappers.<CommonGroup>query().lambda() |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public String getGroupIdsByFuzzy(String tenantId, String groupNames, String groupType, Integer groupCategory) { |
| | | LambdaQueryWrapper<CommonGroup> queryWrapper = Wrappers.<CommonGroup>query().lambda().eq(CommonGroup::getTenantId, tenantId).eq(CommonGroup::getGroupType, groupType).eq(CommonGroup::getGroupCategory, groupCategory); |
| | | queryWrapper.and(wrapper -> { |
| | | List<String> names = Func.toStrList(groupNames); |
| | | names.forEach(name -> { |
| | | wrapper.like(CommonGroup::getName, name).or(); |
| | | }); |
| | | }); |
| | | /* |
| | | Wrapper wrapper = (LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, tenantId)).eq((v0) -> { |
| | |
| | | return v0.getName(); |
| | | }, name)).or(); |
| | | }); |
| | | }); |
| | | List<CommonGroup> groupList = this.baseMapper.selectList(wrapper); |
| | | });*/ |
| | | List<CommonGroup> groupList = this.baseMapper.selectList(queryWrapper); |
| | | if (groupList != null && groupList.size() > 0) { |
| | | return (String) groupList.stream().map(group -> { |
| | | return Func.toStr(group.getId()); |
| | | }).distinct().collect(Collectors.joining(",")); |
| | | return groupList.stream().map(group -> Func.toStr(group.getId())).distinct().collect(Collectors.joining(",")); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<String> getGroupNames(String groupIds) { |
| | | return this.baseMapper.getGroupNames(Func.toLongArray(groupIds)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public boolean removeGroup(String ids) { |
| | | Long cnt = this.baseMapper.selectCount(Wrappers.<CommonGroup>query().lambda().in(CommonGroup::getParentId, Func.toLongList(ids))); |
| | | /* |
| | | Long cnt = this.baseMapper.selectCount((Wrapper) Wrappers.query().lambda().in((v0) -> { |
| | | return v0.getParentId(); |
| | | }, Func.toLongList(ids))); |
| | | }, Func.toLongList(ids)));*/ |
| | | if (cnt.longValue() > 0) { |
| | | throw new ServiceException(MessageUtils.message("cps.group.delete.child.node", new Object[0])); |
| | | } |
| | | return removeByIds(Func.toLongList(ids)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public CommonGroup insert(CommonGroup group) { |
| | | if (Func.isEmpty(group.getParentId())) { |
| | | group.setTenantId(AuthUtil.getTenantId()); |
| | |
| | | return group; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public CommonGroup update(CommonGroup group) { |
| | | validateGroup(group); |
| | | saveOrUpdate(group); |
| | | return group; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public void move(Long id, Long parentId, String groupType, Integer groupCategory) { |
| | | CommonGroup group = (CommonGroup) getById(id); |
| | | if (group.getParentId().equals(id)) { |
| | |
| | | update(group); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroup> getGroupChildren(Long parentId, boolean recursive, String groupType, Integer groupCategory) { |
| | | if (!recursive) { |
| | | return this.baseMapper.selectList(Wrappers.<CommonGroup>query().lambda() |
| | | .eq(CommonGroup::getParentId, parentId) |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory)); |
| | | /* |
| | | return this.baseMapper.selectList((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, parentId)).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)); |
| | | }, groupCategory));*/ |
| | | } |
| | | if (null == parentId) { |
| | | return this.baseMapper.selectList( |
| | | Wrappers.<CommonGroup>query().lambda() |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory)); |
| | | /* |
| | | return this.baseMapper.selectList((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)); |
| | | */ |
| | | } |
| | | String codeOrDefault = getCodeOrDefault(parentId); |
| | | return this.baseMapper.selectList(Wrappers.<CommonGroup>query().lambda() |
| | | .likeRight(CommonGroup::getCode, codeOrDefault) |
| | | .ne(CommonGroup::getId, parentId)); |
| | | /* |
| | | return this.baseMapper.selectList((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().likeRight((v0) -> { |
| | | return v0.getCode(); |
| | | }, codeOrDefault)).ne((v0) -> { |
| | | return v0.getId(); |
| | | }, parentId)); |
| | | }, parentId));*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<CommonGroupVO> search(String groupName, Long parentId, String groupType, Integer groupCategory) { |
| | | Wrapper wrapper = (LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | LambdaQueryWrapper<CommonGroup> wrapper = Wrappers.<CommonGroup>query().lambda().eq(CommonGroup::getGroupType, groupType).eq(CommonGroup::getGroupCategory, groupCategory); |
| | | /*Wrapper wrapper = (LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory); |
| | | }, groupCategory);*/ |
| | | if (Func.isNotEmpty(groupName)) { |
| | | wrapper.like((v0) -> { |
| | | return v0.getName(); |
| | |
| | | return CommonGroupConvert.INSTANCE.convert(groupList); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<Long> getCommonGroupChildIds(String code, String groupType, Integer groupCategory) { |
| | | List<CommonGroup> childList = getCommonGroupChildList(code, groupType, groupCategory, null); |
| | | if (Func.isNotEmpty(childList)) { |
| | | List<Long> groupIdList = (List) childList.stream().map((v0) -> { |
| | | List<Long> groupIdList = childList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | return groupIdList; |
| | |
| | | } |
| | | |
| | | private List<CommonGroup> getCommonGroupChildList(String code, String groupType, Integer groupCategory, Integer status) { |
| | | return this.baseMapper.selectList((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).eq(Func.isNotEmpty(status), (v0) -> { |
| | | return v0.getStatus(); |
| | | }, status).likeRight(Func.isNotEmpty(code), (v0) -> { |
| | | return v0.getCode(); |
| | | }, code)); |
| | | return this.baseMapper.selectList(Wrappers.<CommonGroup>query().lambda().eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory).eq(Func.isNotEmpty(status), CommonGroup::getStatus, status).likeRight(Func.isNotEmpty(code), CommonGroup::getCode, code)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public HashMap<String, Long> getCommonGroupNameMap(String groupType, Integer groupCategory) { |
| | | return getCommonGroupMap(null, groupType, groupCategory, null); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public HashMap<String, Long> getCommonGroupNameMap(String code, String groupType, Integer groupCategory) { |
| | | return getCommonGroupMap(code, groupType, groupCategory, null); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public HashMap<String, Long> getCommonGroupNameMap(String groupType, Integer groupCategory, Integer status) { |
| | | return getCommonGroupMap(null, groupType, groupCategory, status); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public HashMap<String, Long> getCommonGroupNameMap(String code, String groupType, Integer groupCategory, Integer status) { |
| | | return getCommonGroupMap(code, groupType, groupCategory, status); |
| | | } |
| | |
| | | if (Func.isEmpty(childList)) { |
| | | return resultMap; |
| | | } |
| | | Map<Long, List<CommonGroup>> dataMap = (Map) childList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | Map<Long, List<CommonGroup>> dataMap = childList.stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getParentId(); |
| | | })); |
| | | List<CommonGroup> commonGroups = dataMap.get(BladeConstant.TOP_PARENT_ID); |
| | |
| | | for (int i = 0; i < codes.length; i++) { |
| | | codeList.add(code.substring(0, 5 * (i + 1))); |
| | | } |
| | | List<CommonGroup> parentList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).eq(Func.isNotEmpty(status), (v0) -> { |
| | | return v0.getStatus(); |
| | | }, status).in((v0) -> { |
| | | return v0.getCode(); |
| | | }, codeList)); |
| | | //CommonGroup::getCode |
| | | List<CommonGroup> parentList = list( Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(Func.isNotEmpty(status), CommonGroup::getStatus, status) |
| | | .in(CommonGroup::getCode, codeList)); |
| | | if (Func.isNotEmpty(parentList)) { |
| | | id = (Long) parentList.stream().filter(x -> { |
| | | return x.getCode().equals(code); |
| | | }).map((v0) -> { |
| | | return v0.getId(); |
| | | }).findFirst().orElse(id); |
| | | id = parentList.stream().filter(x -> x.getCode().equals(code)).map(CommonGroup::getId).findFirst().orElse(id); |
| | | parentName = getParentName(codeList, parentList); |
| | | } |
| | | } |
| | |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public CommonGroup getRootNode(String groupType, Integer groupCategory) { |
| | | List<CommonGroup> commonGroupList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, BladeConstant.TOP_PARENT_ID)); |
| | | //CommonGroup::getParentId |
| | | List<CommonGroup> commonGroupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(CommonGroup::getParentId, BladeConstant.TOP_PARENT_ID)); |
| | | |
| | | if (Func.isEmpty(commonGroupList) || commonGroupList.size() > 1) { |
| | | throw new IllegalArgumentException(ROOT_NODE_CONFIGURE_ERROR); |
| | | } |
| | | return commonGroupList.get(0); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public Long getRootNodeId(String groupType, Integer groupCategory) { |
| | | return getRootNode(groupType, groupCategory).getId(); |
| | | } |
| | | |
| | | private String getParentName(List<String> codeList, List<CommonGroup> parentList) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | Map<String, String> map = (Map) parentList.stream().filter(x -> { |
| | | Map<String, String> map = parentList.stream().filter(x -> { |
| | | return !BladeConstant.TOP_PARENT_ID.equals(x.getParentId()); |
| | | }).collect(Collectors.toMap((v0) -> { |
| | | return v0.getCode(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public BladeFile importCommonGroup(List<CommonGroupImport> data, CommonGroupTypeVO commonGroupTypeVO) { |
| | | if (Func.isEmpty(data)) { |
| | |
| | | } |
| | | } |
| | | if (!flag.booleanValue()) { |
| | | MultipartFile multipartFile = ExcelUtil.exportFillTemplateToMultipartFile(ExcelConstant.DIRECTORY + "organizationFailTemplate" + ExcelConstant.SUFFIX, MessageUtils.message("excel.import.failed.report.name", new Object[0]) + ExcelConstant.SUFFIX, "部门信息表", (List) data.stream().filter(x -> { |
| | | MultipartFile multipartFile = ExcelUtil.exportFillTemplateToMultipartFile(ExcelConstant.DIRECTORY + "organizationFailTemplate" + ExcelConstant.SUFFIX, MessageUtils.message("excel.import.failed.report.name", new Object[0]) + ExcelConstant.SUFFIX, "部门信息表", data.stream().filter(x -> { |
| | | return Func.isNotEmpty(x.getFailReason()); |
| | | }).collect(Collectors.toList()), (Object) null, (AbstractMergeStrategy) null); |
| | | BladeFile bladeFile = this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationGroupVO> listWorkstationGroup(String groupType, String groupCategory, String groupTag) { |
| | | List<CommonGroup> commonGroupList = list(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(Func.isNotBlank(groupType), CommonGroup::getGroupType, groupType) |
| | | .eq(Func.isNotBlank(groupCategory), CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(Func.isNotBlank(groupTag), CommonGroup::getGroupTag, groupTag)); |
| | | /* |
| | | List<CommonGroup> commonGroupList = list(Wrappers.lambdaQuery().eq(Func.isNotBlank(groupType), (v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType).eq(Func.isNotBlank(groupCategory), (v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory).eq(Func.isNotBlank(groupTag), (v0) -> { |
| | | return v0.getGroupTag(); |
| | | }, groupTag)); |
| | | }, groupTag));*/ |
| | | List<WorkstationGroupVO> result = CommonGroupConvert.INSTANCE.convert1(commonGroupList); |
| | | if (CollectionUtil.isNotEmpty(result)) { |
| | | List<String> codeList = (List) result.stream().map((v0) -> { |
| | | List<String> codeList = result.stream().map((v0) -> { |
| | | return v0.getCode(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(codeList)) { |
| | | List<CommonGroup> groupList = list((Wrapper) Wrappers.lambdaQuery().eq(Func.isNotBlank(groupType), (v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType).eq(Func.isNotBlank(groupCategory), (v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory).eq(Func.isNotBlank(groupTag), (v0) -> { |
| | | return v0.getGroupTag(); |
| | | }, groupTag).in((v0) -> { |
| | | return v0.getCode(); |
| | | }, codeList)); |
| | | Map<String, String> map = (Map) groupList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getCode(); |
| | | }, (v0) -> { |
| | | return v0.getName(); |
| | | }, v1, v2 -> { |
| | | return v1; |
| | | })); |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(Func.isNotBlank(groupType), CommonGroup::getGroupType, groupType) |
| | | .eq(Func.isNotBlank(groupCategory), CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(Func.isNotBlank(groupTag),CommonGroup::getGroupTag, groupTag).in(CommonGroup::getCode, codeList)); |
| | | |
| | | Map<String, String> map = groupList.stream().collect(Collectors.toMap(CommonGroup::getCode, CommonGroup::getName, (v1, v2) -> v1)); |
| | | |
| | | result.forEach(i -> { |
| | | i.setPath(CommonGroup.appendName(i.getCode(), map)); |
| | | }); |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationInGroupVO> groupWorkstationListType(CommonGroupTypeVO commonGroupTypeVO) { |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, commonGroupTypeVO.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroupTypeVO.getGroupCategory()) |
| | | .orderByAsc(CommonGroup::getSort)); |
| | | /* |
| | | List<CommonGroup> groupList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupTypeVO.getGroupType())).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, commonGroupTypeVO.getGroupCategory())).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | List<Long> groupIds = (List) groupList.stream().map((v0) -> { |
| | | }));*/ |
| | | List<Long> groupIds = groupList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list(Wrappers.lambdaQuery().in(Func.isNotEmpty(groupIds), (v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupIds)); |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery().in(Func.isNotEmpty(groupIds), CommonGroupOfItem::getGroupId, groupIds)); |
| | | List<Workstation> workstations = this.workstationService.listMachine(commonGroupTypeVO.getStatus(), commonGroupTypeVO.getKeyword()); |
| | | List<WorkstationInGroupVO> list = (List) groupList.stream().filter(o -> { |
| | | List<WorkstationInGroupVO> list = groupList.stream().filter(o -> { |
| | | return Func.isNotEmpty(o.getParentId()); |
| | | }).map(o2 -> { |
| | | return WorkstationInGroupVO.builder().id(o2.getId()).parentId(o2.getParentId()).title(o2.getName()).code("").isWorkstation(Boolean.FALSE).isGroup(Boolean.TRUE).groupTag(o2.getGroupTag()).build(); |
| | | }).collect(Collectors.toList()); |
| | | list.addAll((Collection) workstations.stream().flatMap(o1 -> { |
| | | list.addAll( workstations.stream().flatMap(o1 -> { |
| | | Long id = o1.getId(); |
| | | return itemList.stream().filter(o22 -> { |
| | | Integer distinguish = commonGroupTypeVO.getDistinguish(); |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationInGroupVO> groupWorkstationListLazy(Long groupId) { |
| | | List<CommonGroup> commonGroupList = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, groupId)).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | List<WorkstationInGroupVO> collect = (List) commonGroupList.stream().map(commonGroup -> { |
| | | //CommonGroup::getSort |
| | | List<CommonGroup> commonGroupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getParentId, groupId).orderByAsc(CommonGroup::getSort)); |
| | | List<WorkstationInGroupVO> collect = commonGroupList.stream().map(commonGroup -> { |
| | | return WorkstationInGroupVO.builder().parentId(groupId).isWorkstation(false).isGroup(true).code(commonGroup.getCode()).title(commonGroup.getName()).groupTag(commonGroup.getGroupTag()).id(commonGroup.getId()).build(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupId)).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | Map<Long, Long> workstationIdToGroupId = (Map) commonGroupOfItemList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getItemId(); |
| | | }, (v0) -> { |
| | | return v0.getGroupId(); |
| | | })); |
| | | //CommonGroupOfItem::getGroupType |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .eq(CommonGroupOfItem::getGroupId, groupId).eq(CommonGroupOfItem::getGroupType, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | |
| | | Map<Long, Long> workstationIdToGroupId = commonGroupOfItemList.stream().collect(Collectors.toMap(CommonGroupOfItem::getItemId, CommonGroupOfItem::getGroupId)); |
| | | if (Func.isNotEmpty(commonGroupOfItemList)) { |
| | | List<Long> workstationIds = (List<Long>)commonGroupOfItemList.stream().map(CommonGroupOfItem::getItemId).collect(Collectors.toList()); |
| | | /* |
| | | List<Long> workstationIds = (List) commonGroupOfItemList.stream().map((v0) -> { |
| | | return v0.getItemId(); |
| | | }).collect(Collectors.toList()); |
| | | List<Workstation> workstations = (List) this.workstationService.listByIds(workstationIds).stream().filter(s -> { |
| | | }).collect(Collectors.toList());*/ |
| | | List<Workstation> workstations = this.workstationService.listByIds(workstationIds).stream().filter(s -> { |
| | | return CommonConstant.ENABLE.equals(s.getStatus()); |
| | | }).filter((v0) -> { |
| | | return Func.isNotEmpty(v0); |
| | | }).collect(Collectors.toList()); |
| | | List<WorkstationInGroupVO> collect1 = (List) workstations.stream().map(workstation -> { |
| | | List<WorkstationInGroupVO> collect1 = workstations.stream().map(workstation -> { |
| | | return WorkstationInGroupVO.builder().isWorkstation(true).isGroup(false).id(workstation.getId()).title(workstation.getName()).code(workstation.getName()).parentId((Long) workstationIdToGroupId.get(workstation.getId())).supportCncRw(workstation.getSupportCncRw()).build(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isNotEmpty(collect1)) { |
| | |
| | | } |
| | | |
| | | private List<WorkstationInGroupVO> groupWorkstationList(Long groupId) { |
| | | List<CommonGroup> commonGroupList = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, groupId)).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | //CommonGroup::getSort |
| | | List<CommonGroup> commonGroupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getParentId, groupId).orderByAsc(CommonGroup::getSort)); |
| | | List<WorkstationInGroupVO> collect = Lists.newArrayList(); |
| | | if (Func.isNotEmpty(commonGroupList)) { |
| | | List<Long> ids = (List) commonGroupList.stream().map((v0) -> { |
| | | List<Long> ids = commonGroupList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).distinct().collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery().in(CommonGroupOfItem::getGroupId, ids) |
| | | .eq(CommonGroupOfItem::getGroupType, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | /* |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, ids)).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | Map<Long, Long> workstationIdToGroupId = (Map) commonGroupOfItemList.stream().collect(Collectors.toMap((v0) -> { |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName()));*/ |
| | | Map<Long, Long> workstationIdToGroupId = commonGroupOfItemList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getItemId(); |
| | | }, (v0) -> { |
| | | return v0.getGroupId(); |
| | | })); |
| | | if (Func.isNotEmpty(commonGroupOfItemList)) { |
| | | List<Long> workstationIds = (List) commonGroupOfItemList.stream().map((v0) -> { |
| | | List<Long> workstationIds = commonGroupOfItemList.stream().map((v0) -> { |
| | | return v0.getItemId(); |
| | | }).collect(Collectors.toList()); |
| | | List<Workstation> workstations = (List) this.workstationService.listByIds(workstationIds).stream().filter(s -> { |
| | | List<Workstation> workstations = this.workstationService.listByIds(workstationIds).stream().filter(s -> { |
| | | return CommonConstant.ENABLE.equals(s.getStatus()); |
| | | }).filter((v0) -> { |
| | | return Func.isNotEmpty(v0); |
| | | }).collect(Collectors.toList()); |
| | | List<WorkstationInGroupVO> collect1 = (List) workstations.stream().map(workstation -> { |
| | | List<WorkstationInGroupVO> collect1 = workstations.stream().map(workstation -> { |
| | | return WorkstationInGroupVO.builder().isWorkstation(true).isGroup(false).id(workstation.getId()).title(workstation.getName()).code(workstation.getName()).parentId((Long) workstationIdToGroupId.get(workstation.getId())).supportCncRw(workstation.getSupportCncRw()).build(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isNotEmpty(collect1)) { |
| | |
| | | return collect; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationInGroupVO> groupFtpDirectoryListLazy(Long groupId) { |
| | | List<CommonGroup> commonGroupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getParentId, groupId).orderByAsc(Arrays.asList(CommonGroup::getSort)) ); |
| | | |
| | | /* |
| | | List<CommonGroup> commonGroupList = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, groupId)).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | List<WorkstationInGroupVO> collect = (List) commonGroupList.stream().map(commonGroup -> { |
| | | }));*/ |
| | | List<WorkstationInGroupVO> collect = commonGroupList.stream().map(commonGroup -> { |
| | | return WorkstationInGroupVO.builder().parentId(groupId).isWorkstation(false).isGroup(true).code(commonGroup.getCode()).title(commonGroup.getName()).groupTag(commonGroup.getGroupTag()).id(commonGroup.getId()).build(); |
| | | }).collect(Collectors.toList()); |
| | | List<Long> bindingFtps = (List) this.wsRelationTdService.list().stream().map((v0) -> { |
| | | List<Long> bindingFtps = this.wsRelationTdService.list().stream().map((v0) -> { |
| | | return v0.getWorkstationId(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupId)).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | Map<Long, Long> workstationIdToGroupId = (Map) commonGroupOfItemList.stream().collect(Collectors.toMap((v0) -> { |
| | | //CommonGroupOfItem::getGroupType |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .eq(CommonGroupOfItem::getGroupId, groupId).eq(CommonGroupOfItem::getGroupType, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | Map<Long, Long> workstationIdToGroupId = commonGroupOfItemList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getItemId(); |
| | | }, (v0) -> { |
| | | return v0.getGroupId(); |
| | | })); |
| | | if (Func.isNotEmpty(commonGroupOfItemList)) { |
| | | List<Long> workstationIds = (List) ((List) commonGroupOfItemList.stream().map((v0) -> { |
| | | List<Long> workstationIds = (commonGroupOfItemList.stream().map((v0) -> { |
| | | return v0.getItemId(); |
| | | }).collect(Collectors.toList())).stream().filter(item -> { |
| | | return !bindingFtps.contains(item); |
| | | }).collect(Collectors.toList()); |
| | | List<Workstation> workstations = (List) this.workstationService.listByIds(workstationIds).stream().filter((v0) -> { |
| | | List<Workstation> workstations = this.workstationService.listByIds(workstationIds).stream().filter((v0) -> { |
| | | return Func.isNotEmpty(v0); |
| | | }).collect(Collectors.toList()); |
| | | List<WorkstationInGroupVO> workstationInGroupVOList = (List) workstations.stream().map(workstation -> { |
| | | List<WorkstationInGroupVO> workstationInGroupVOList = workstations.stream().map(workstation -> { |
| | | return WorkstationInGroupVO.builder().isWorkstation(true).isGroup(false).id(workstation.getId()).title(workstation.getName()).code(workstation.getName()).parentId((Long) workstationIdToGroupId.get(workstation.getId())).supportCncRw(workstation.getSupportCncRw()).build(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isNotEmpty(workstationInGroupVOList)) { |
| | |
| | | return collect; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationInGroupVO> groupFtpDirectoryWorkstationList(CommonGroupFtpVO commonGroupFtpVO) { |
| | | List<CommonGroup> groupList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupFtpVO.getGroupType())).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, commonGroupFtpVO.getGroupCategory())).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | List<Long> groupIds = (List) groupList.stream().map((v0) -> { |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, commonGroupFtpVO.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroupFtpVO.getGroupCategory()) |
| | | .orderByAsc(CommonGroup::getSort)); |
| | | |
| | | List<Long> groupIds = groupList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list((Wrapper) Wrappers.lambdaQuery().in(Func.isNotEmpty(groupIds), (v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupIds).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupFtpVO.getGroupType())); |
| | | List<Long> bindingFtps = (List) this.wsRelationTdService.list().stream().map((v0) -> { |
| | | //CommonGroupOfItem::getGroupType |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .in(Func.isNotEmpty(groupIds), CommonGroupOfItem::getGroupId, groupIds) |
| | | .eq(CommonGroupOfItem::getGroupType, commonGroupFtpVO.getGroupType())); |
| | | |
| | | List<Long> bindingFtps = this.wsRelationTdService.list().stream().map((v0) -> { |
| | | return v0.getWorkstationId(); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | if (Func.isNotEmpty(commonGroupFtpVO.getTransferDirectorId())) { |
| | | List<DncWsRelationTd> list = this.wsRelationTdService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getTransferDirectorId(); |
| | | }, commonGroupFtpVO.getTransferDirectorId())); |
| | | //DncWsRelationTd::getTransferDirectorId |
| | | List<DncWsRelationTd> list = this.wsRelationTdService.list(Wrappers.<DncWsRelationTd>lambdaQuery() |
| | | .eq(DncWsRelationTd::getTransferDirectorId, commonGroupFtpVO.getTransferDirectorId())); |
| | | if (Func.isNotEmpty(list)) { |
| | | List<Long> ftpRelationIds = (List) list.stream().map((v0) -> { |
| | | List<Long> ftpRelationIds = list.stream().map((v0) -> { |
| | | return v0.getWorkstationId(); |
| | | }).collect(Collectors.toList()); |
| | | if (Func.isNotEmpty(ftpRelationIds)) { |
| | | bindingFtps = (List) bindingFtps.stream().filter(s -> { |
| | | bindingFtps = bindingFtps.stream().filter(s -> { |
| | | return !ftpRelationIds.contains(s); |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | } |
| | | List<Long> finalBindingFtps = bindingFtps; |
| | | List<Workstation> workstations = (List) this.workstationService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getStatus(); |
| | | }, commonGroupFtpVO.getStatus() == null ? CommonConstant.ENABLE : commonGroupFtpVO.getStatus())).stream().filter(item -> { |
| | | //Workstation::getStatus |
| | | List<Workstation> workstations = this.workstationService.list(Wrappers.<Workstation>lambdaQuery() |
| | | .eq(Workstation::getStatus, commonGroupFtpVO.getStatus() == null ? CommonConstant.ENABLE : commonGroupFtpVO.getStatus())).stream().filter(item -> { |
| | | return !finalBindingFtps.contains(item.getId()); |
| | | }).collect(Collectors.toList()); |
| | | List<WorkstationInGroupVO> list2 = (List) groupList.stream().filter(o -> { |
| | | |
| | | List<WorkstationInGroupVO> list2 = groupList.stream().filter(o -> { |
| | | return Func.isNotEmpty(o.getParentId()); |
| | | }).map(o2 -> { |
| | | return WorkstationInGroupVO.builder().id(o2.getId()).parentId(o2.getParentId()).title(o2.getName()).code("").isWorkstation(Boolean.FALSE).isGroup(Boolean.TRUE).groupTag(o2.getGroupTag()).build(); |
| | | }).collect(Collectors.toList()); |
| | | list2.addAll((Collection) workstations.stream().flatMap(o1 -> { |
| | | |
| | | list2.addAll(workstations.stream().flatMap(o1 -> { |
| | | Long id = o1.getId(); |
| | | return itemList.stream().filter(o22 -> { |
| | | return id.equals(o22.getItemId()); |
| | |
| | | return list2; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<MdcWorkStationGroupVO> getMdcGroup() { |
| | | ParamBiz param = new ParamBiz(); |
| | | param.setUserId(AuthUtil.getUserId()); |
| | | param.setParamKey("mdc_chosen_groups"); |
| | | ParamBiz detail = (ParamBiz) this.paramService.getOne(Condition.getQueryWrapper(param)); |
| | | List<CommonGroup> groupList = list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | //CommonGroup::getGroupType |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getGroupType, CommonGroupTypeEnum.WORKSTATION.getName())); |
| | | if (detail == null) { |
| | | return new ArrayList(); |
| | | return new ArrayList<>(); |
| | | } |
| | | List<MdcWorkStationGroupVO> result = JSONArray.parseArray(detail.getParamValue(), MdcWorkStationGroupVO.class); |
| | | if (CollectionUtil.isEmpty(result)) { |
| | | return new ArrayList(); |
| | | return new ArrayList<>(); |
| | | } |
| | | Set<Long> groupIdSet = (Set) groupList.stream().map((v0) -> { |
| | | Set<Long> groupIdSet = groupList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toSet()); |
| | | Iterator<MdcWorkStationGroupVO> ite = result.iterator(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean deleteGroup(Long groupId) { |
| | | CommonGroup commonGroup = (CommonGroup) getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getId(); |
| | | }, groupId)); |
| | | CommonGroup commonGroup = (CommonGroup) getOne(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getId, groupId)); |
| | | List<String> dictItems = getDictItems(); |
| | | deleteCheckGroup(commonGroup); |
| | | verificationProductionLineCommonGroup(commonGroup); |
| | | validCraftVersionBing(groupId); |
| | | String groupTag = commonGroup.getGroupTag(); |
| | | List<Long> groupIdList = (List) this.baseMapper.getAllSubGroup(groupId, commonGroup.getGroupType(), commonGroup.getGroupCategory()).stream().map((v0) -> { |
| | | List<Long> groupIdList = this.baseMapper.getAllSubGroup(groupId, commonGroup.getGroupType(), commonGroup.getGroupCategory()).stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list((Wrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupIdList)); |
| | | //CommonGroupOfItem::getGroupId |
| | | List<CommonGroupOfItem> commonGroupOfItemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .in(CommonGroupOfItem::getGroupId, groupIdList)); |
| | | if (Func.isBlank(groupTag)) { |
| | | CommonGroup rootNode = getDefaultGroup(commonGroup.getGroupType(), commonGroup.getGroupCategory()); |
| | | String groupType = commonGroup.getGroupType(); |
| | | if (Func.equals(groupType, CommonGroupConstant.NG_TYPE)) { |
| | | List<CommonGroup> list = list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, groupId)); |
| | | List<CommonGroupOfItem> commonGroupOfItemList2 = this.commonGroupOfItemService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupId)); |
| | | //CommonGroup::getParentId |
| | | List<CommonGroup> list = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getParentId, groupId)); |
| | | List<CommonGroupOfItem> commonGroupOfItemList2 = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery().eq(CommonGroupOfItem::getGroupId, groupId)); |
| | | commonGroupOfItemList2.forEach(c -> { |
| | | c.setGroupId(rootNode.getParentId()); |
| | | }); |
| | |
| | | } |
| | | |
| | | private void validCraftVersionBing(Long groupId) { |
| | | long count = this.lineService.count((Wrapper) Wrappers.lambdaQuery(CraftVersionLine.class).eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupId)); |
| | | long count = this.lineService.count(Wrappers.lambdaQuery(CraftVersionLine.class).eq(CraftVersionLine::getGroupId, groupId)); |
| | | ThrowFun.isTrue(count > 0).throwMessage(MessageUtils.message("cps.common.group.line.bind.version", new Object[0])); |
| | | } |
| | | |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public CommonGroup getDefaultGroup(String groupType, Integer groupCategory) { |
| | | return (CommonGroup) getOne((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).eq((v0) -> { |
| | | return v0.getCode(); |
| | | }, CommonGroupConstant.DEFAULT_CODE)).eq((v0) -> { |
| | | return v0.getName(); |
| | | }, CommonGroupConstant.WORKSTATION_TYPE.equals(groupType) ? CommonGroupConstant.DEFAULT_NAME : CommonGroupConstant.DEFAULT_GROUP_NAME)); |
| | | |
| | | return (CommonGroup) getOne(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(CommonGroup::getCode, CommonGroupConstant.DEFAULT_CODE) |
| | | .eq(CommonGroup::getName, CommonGroupConstant.WORKSTATION_TYPE.equals(groupType) ? CommonGroupConstant.DEFAULT_NAME : CommonGroupConstant.DEFAULT_GROUP_NAME)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<WorkstationInGroupVO> groupWorkstationList(CommonGroupTypeVO commonGroupTypeVO) { |
| | | List<CommonGroup> groupList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupTypeVO.getGroupType())).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, commonGroupTypeVO.getGroupCategory())).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | List<Long> groupIds = (List) groupList.stream().map((v0) -> { |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery().eq(CommonGroup::getGroupType, commonGroupTypeVO.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroupTypeVO.getGroupCategory()) |
| | | .orderByAsc(CommonGroup::getSort)); |
| | | List<Long> groupIds = groupList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list((Wrapper) Wrappers.lambdaQuery().in(Func.isNotEmpty(groupIds), (v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupIds).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupTypeVO.getGroupType())); |
| | | List<Workstation> workstations = this.workstationService.list(((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getStatus(); |
| | | }, commonGroupTypeVO.getStatus() == null ? CommonConstant.ENABLE : commonGroupTypeVO.getStatus())).eq(Func.isNotEmpty(commonGroupTypeVO.getWorkType()), (v0) -> { |
| | | return v0.getDeviceType(); |
| | | }, commonGroupTypeVO.getWorkType()).in(Func.isNotEmpty(commonGroupTypeVO.getWorkstationIdList()), (v0) -> { |
| | | return v0.getId(); |
| | | }, commonGroupTypeVO.getWorkstationIdList())); |
| | | Map<Long, String> groupMap = (Map) groupList.stream().collect(Collectors.toMap((v0) -> { |
| | | |
| | | //CommonGroupOfItem::getId |
| | | List<CommonGroupOfItem> itemList = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .in(Func.isNotEmpty(groupIds), CommonGroupOfItem::getGroupId, groupIds) |
| | | .eq(CommonGroupOfItem::getGroupType, commonGroupTypeVO.getGroupType())); |
| | | //Workstation::getDeviceType |
| | | List<Workstation> workstations = this.workstationService.list(Wrappers.<Workstation>lambdaQuery() |
| | | .eq(Workstation::getStatus, commonGroupTypeVO.getStatus() == null ? CommonConstant.ENABLE : commonGroupTypeVO.getStatus()) |
| | | .eq(Func.isNotEmpty(commonGroupTypeVO.getWorkType()),Workstation::getDeviceType, commonGroupTypeVO.getWorkType()) |
| | | .in(Func.isNotEmpty(commonGroupTypeVO.getWorkstationIdList()),Workstation::getId, commonGroupTypeVO.getWorkstationIdList())); |
| | | Map<Long, String> groupMap = groupList.stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getId(); |
| | | }, (v0) -> { |
| | | return v0.getName(); |
| | | })); |
| | | List<WorkstationInGroupVO> list = (List) groupList.stream().filter(o -> { |
| | | List<WorkstationInGroupVO> list = groupList.stream().filter(o -> { |
| | | return Func.isNotEmpty(o.getParentId()); |
| | | }).map(o2 -> { |
| | | return WorkstationInGroupVO.builder().id(o2.getId()).parentId(o2.getParentId()).parentName((String) groupMap.get(o2.getParentId())).title(o2.getName()).code("").isWorkstation(Boolean.FALSE).isGroup(Boolean.TRUE).groupTag(o2.getGroupTag()).build(); |
| | | }).collect(Collectors.toList()); |
| | | list.addAll((Collection) workstations.stream().flatMap(o1 -> { |
| | | list.addAll(workstations.stream().flatMap(o1 -> { |
| | | Long id = o1.getId(); |
| | | return itemList.stream().filter(o22 -> { |
| | | return id.equals(o22.getItemId()); |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public Map<Long, Set<Long>> groupWorkstationMap(List<String> groupIds) { |
| | | List<CommonGroupOfItem> groupOfItems = this.commonGroupOfItemService.list(Wrappers.lambdaQuery().in(Func.isNotEmpty(groupIds), (v0) -> { |
| | | return v0.getGroupId(); |
| | | }, groupIds)); |
| | | return (Map) groupOfItems.stream().collect(Collectors.groupingBy((v0) -> { |
| | | //CommonGroupOfItem::getGroupId |
| | | List<CommonGroupOfItem> groupOfItems = this.commonGroupOfItemService.list(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .in(Func.isNotEmpty(groupIds), CommonGroupOfItem::getGroupId, groupIds)); |
| | | return groupOfItems.stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, Collectors.mapping((v0) -> { |
| | | return v0.getItemId(); |
| | | }, Collectors.toSet()))); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.cps.service.ICommonGroupService |
| | | @Override |
| | | public List<JimuTreeVO> groupWorkstationListJimu(String pid) { |
| | | List<JimuTreeVO> result = new ArrayList<>(); |
| | | if (Func.isEmpty(pid)) { |
| | | pid = String.valueOf(CommonGroupConstant.ROOT); |
| | | } |
| | | List<CommonGroup> groupList = list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.WORKSTATION.getName())).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, CommonGroupConstant.DEFAULT_CATEGORY)).eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, pid)).orderByAsc((v0) -> { |
| | | return v0.getSort(); |
| | | })); |
| | | |
| | | List<CommonGroup> groupList = list(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, CommonGroupTypeEnum.WORKSTATION.getName()) |
| | | .eq(CommonGroup::getGroupCategory, CommonGroupConstant.DEFAULT_CATEGORY) |
| | | .eq(CommonGroup::getParentId, pid) |
| | | .orderByAsc(CommonGroup::getSort)); |
| | | |
| | | List<Workstation> workstationList = this.workstationMapper.listWorkstationDataByGroup(pid); |
| | | String finalPid = pid; |
| | | if (Func.isNotEmpty(groupList)) { |
| | |
| | | } |
| | | |
| | | private boolean getOrCreateIdUnable(Long parentId, String name, CommonGroupTypeVO commonGroupTypeVO) { |
| | | CommonGroup commonGroup = getOne(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, commonGroupTypeVO.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroupTypeVO.getGroupCategory()) |
| | | .eq(CommonGroup::getParentId, Func.isEmpty(parentId) ? BladeConstant.TOP_PARENT_ID : parentId) |
| | | .eq(CommonGroup::getStatus, CommonConstant.DEACTIVATE) |
| | | .eq(CommonGroup::getName, name)); |
| | | /* |
| | | CommonGroup commonGroup = (CommonGroup) getOne((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupTypeVO.getGroupType())).eq((v0) -> { |
| | |
| | | return v0.getStatus(); |
| | | }, CommonConstant.DEACTIVATE)).eq((v0) -> { |
| | | return v0.getName(); |
| | | }, name)); |
| | | }, name));*/ |
| | | if (commonGroup != null) { |
| | | return Boolean.TRUE.booleanValue(); |
| | | return true; |
| | | } |
| | | return Boolean.FALSE.booleanValue(); |
| | | return false; |
| | | } |
| | | |
| | | private Long getOrCreateId(Long parentId, String name, CommonGroupTypeVO commonGroupTypeVO) { |
| | | CommonGroup commonGroup = getOne(Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, commonGroupTypeVO.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroupTypeVO.getGroupCategory()) |
| | | .eq(CommonGroup::getParentId, Func.isEmpty(parentId) ? BladeConstant.TOP_PARENT_ID : parentId) |
| | | .eq(CommonGroup::getStatus, CommonConstant.ENABLE) |
| | | .eq(CommonGroup::getName, name)); |
| | | /* |
| | | CommonGroup commonGroup = (CommonGroup) getOne((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroupTypeVO.getGroupType())).eq((v0) -> { |
| | |
| | | return v0.getStatus(); |
| | | }, CommonConstant.ENABLE)).eq((v0) -> { |
| | | return v0.getName(); |
| | | }, name)); |
| | | }, name));*/ |
| | | if (Func.isNotEmpty(commonGroup)) { |
| | | return commonGroup.getId(); |
| | | } |
| | |
| | | protected void validateGroup(CommonGroup commonGroup) { |
| | | Long pId = Long.valueOf(Func.isEmpty(commonGroup.getParentId()) ? 0L : commonGroup.getParentId().longValue()); |
| | | Long id = Long.valueOf(Func.isEmpty(commonGroup.getId()) ? 0L : commonGroup.getId().longValue()); |
| | | |
| | | List<CommonGroup> siblings = this.baseMapper.selectList( |
| | | Wrappers.<CommonGroup>query().lambda() |
| | | .eq(CommonGroup::getGroupType, commonGroup.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroup.getGroupCategory()) |
| | | .eq(CommonGroup::getParentId, pId) |
| | | .eq(CommonGroup::getStatus, CommonConstant.ENABLE) |
| | | .ne(CommonGroup::getId, id)); |
| | | |
| | | /* |
| | | List<CommonGroup> siblings = this.baseMapper.selectList((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroup.getGroupType())).eq((v0) -> { |
| | |
| | | return v0.getStatus(); |
| | | }, CommonConstant.ENABLE)).ne((v0) -> { |
| | | return v0.getId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | if (siblings.stream().anyMatch(g -> { |
| | | return g.getName().equals(commonGroup.getName()); |
| | | })) { |
| | |
| | | protected void validateUnableGroup(CommonGroup commonGroup) { |
| | | Long pId = Long.valueOf(Func.isEmpty(commonGroup.getParentId()) ? 0L : commonGroup.getParentId().longValue()); |
| | | Long id = Long.valueOf(Func.isEmpty(commonGroup.getId()) ? 0L : commonGroup.getId().longValue()); |
| | | List<CommonGroup> siblings = this.baseMapper.selectList( |
| | | Wrappers.<CommonGroup>query().lambda() |
| | | .eq(CommonGroup::getGroupType, commonGroup.getGroupType()) |
| | | .eq(CommonGroup::getGroupCategory, commonGroup.getGroupCategory()) |
| | | .eq(CommonGroup::getParentId, pId) |
| | | .eq(CommonGroup::getStatus, CommonConstant.DEACTIVATE) |
| | | .ne(CommonGroup::getId, id)); |
| | | /* |
| | | List<CommonGroup> siblings = this.baseMapper.selectList((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, commonGroup.getGroupType())).eq((v0) -> { |
| | |
| | | return v0.getStatus(); |
| | | }, CommonConstant.DEACTIVATE)).ne((v0) -> { |
| | | return v0.getId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | if (siblings.stream().anyMatch(g -> { |
| | | return g.getName().equals(commonGroup.getName()); |
| | | })) { |
| | |
| | | } |
| | | |
| | | public CommonGroup getLastChildOrNull(Long parentId, String groupType, Integer groupCategory) { |
| | | return this.baseMapper.selectOne( |
| | | Lambda.<CommonGroup>create() |
| | | .eq(CommonGroup::getParentId, parentId) |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .eq(CommonGroup::getStatus, CommonConstant.ENABLE) |
| | | .orderByDesc(CommonGroup::getCode) |
| | | .limit(1)); |
| | | /* |
| | | return (CommonGroup) this.baseMapper.selectOne(((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) Lambda.create().eq((v0) -> { |
| | | return v0.getParentId(); |
| | | }, parentId)).eq((v0) -> { |
| | |
| | | }, CommonConstant.ENABLE)).orderByDesc((v0) -> { |
| | | return v0.getCode(); |
| | | })).limit(1)); |
| | | */ |
| | | } |
| | | } |