| | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyMapper; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyTemplateMapper; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.po.CodeClassifyPO; |
| | | import com.vci.ubcs.code.service.ICodeClassifyService; |
| | | import com.vci.ubcs.code.service.ICodeKeyAttrRepeatService; |
| | |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.*; |
| | | import static com.vci.ubcs.starter.web.util.VciBaseUtil.getTableName; |
| | | |
| | | @Service |
| | | public class CodeClassifyServiceImpl extends ServiceImpl<CodeClassifyMapper, CodeClassify> implements ICodeClassifyService { |
| | |
| | | @Resource |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | @Value("${user-info.tenant-id}") |
| | | private String tenantId; |
| | | @Resource |
| | | private CommonsMapper commonsMapper; |
| | | |
| | | /** |
| | | * 日志 |
| | |
| | | |
| | | @Override |
| | | public IPage<CodeClassifyVO> selectPlCodeClassifyPage(IPage<CodeClassifyVO> page, CodeClassifyVO plCodeClassify) { |
| | | return page.setRecords(codeClassifyMapper.selectPlCodeClassifyPage(page, plCodeClassify)); |
| | | return page.setRecords(codeClassifyMapper.selectPlCodeClassifyPage(page, plCodeClassify,AuthUtil.getTenantId() |
| | | .equals( |
| | | NacosConfigCache |
| | | .getAdminUserInfo() |
| | | .getTenantId() |
| | | ) ? null:AuthUtil.getTenantId())); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public R addSave(CodeClassify codeClassifyEntity) { |
| | | try { |
| | | VciBaseUtil.alertNotNull(codeClassifyEntity.getId(),"主题库编号不能为空!",codeClassifyEntity.getName(),"主题库名称不能为空!"); |
| | | }catch (VciBaseException e){ |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){ |
| | | return R.fail("只有在顶层的主题库分类才能设置业务类型"); |
| | | } |
| | | if(StringUtils.isEmpty(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isBlank(codeClassifyEntity.getBtmTypeId())){ |
| | | return R.fail("主题库关联的业务类型不能为空!"); |
| | | } |
| | | QueryWrapper<CodeClassify> classifyQueryWrapper = new QueryWrapper<>(); |
| | | classifyQueryWrapper.eq("parentCodeClassifyOid",codeClassifyEntity.getParentCodeClassifyOid()); |
| | |
| | | if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){ |
| | | return R.fail("只有在顶层的主题库分类才能设置业务类型"); |
| | | } |
| | | codeClassifyEntity.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | // codeClassifyEntity.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | codeClassifyEntity.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | codeClassifyEntity.setLastModifyTime(new Date()); |
| | | codeClassifyEntity.setTs(new Date()); |
| | | int insertNumber = codeClassifyMapper.updateById(codeClassifyEntity); |
| | |
| | | // .selectOne(Condition.getQueryWrapper(condition,CodeClassify.class)); |
| | | if(detail == null){//不是最新的不让改 |
| | | throw new ServiceException("当前数据不是最新,请刷新后再修改!"); |
| | | // return R.fail("当前数据不是最新,请刷新后再修改!"); |
| | | } |
| | | //校验下级是否有引用 |
| | | if(checkChildIsLinked(detail.getOid())){ |
| | | return R.fail("dataCascadeLinkedNotDelete"); |
| | | } |
| | | if(checkHasChild(detail.getOid())){ |
| | | return R.fail("此数据有下级,无法进行删除!"); |
| | | } |
| | | return R.status(!checkHasChild(detail.getOid())); |
| | | } |
| | |
| | | |
| | | List<CodeClassify> classifyList = codeClassifyMapper.selectStartWithCurrentOid(oid); |
| | | Date now = new Date(); |
| | | String userId = String.valueOf(AuthUtil.getUserId()); |
| | | // String userId = String.valueOf(AuthUtil.getUserId()); |
| | | String account = AuthUtil.getUserAccount(); |
| | | classifyList = classifyList.stream().map(s -> { |
| | | s.setLcStatus(lcStatus); |
| | | s.setTs(now); |
| | | s.setLastModifier(userId); |
| | | s.setLastModifier(account); |
| | | s.setLastModifyTime(now); |
| | | return s; |
| | | }).collect(Collectors.toList()); |
| | |
| | | List<CodeClassifyVO> voList = new ArrayList<CodeClassifyVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifys)){ |
| | | for(CodeClassify s: codeClassifys){ |
| | | CodeClassifyVO vo = codeClassifyDO2VO(s); |
| | | CodeClassifyVO vo = codeClassifyDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | |
| | | lcStatus = treeQueryObject.getConditionMap().getOrDefault("lcStatus",null); |
| | | } |
| | | if(StringUtils.isNotBlank(id) || StringUtils.isNotBlank(lcStatus) ){ |
| | | String tableName = this.getTableName(treeQueryObject.getParentOid(),treeQueryObject.getConditionMap().get("id"), treeQueryObject.getConditionMap().get("lcStatus")); |
| | | doList = codeClassifyMapper |
| | | .selectCodeClassifyDOByTree(treeQueryObject.getConditionMap().get("id"),treeQueryObject.getConditionMap().get("lcStatus"),treeQueryObject.getParentOid(), AuthUtil.getTenantId().equals(this.tenantId) ? "":AuthUtil.getTenantId()); |
| | | .selectCodeClassifyDOByTree( |
| | | treeQueryObject.getConditionMap().get("id"), |
| | | treeQueryObject.getConditionMap().get("lcStatus"), |
| | | treeQueryObject.getParentOid(), |
| | | VciBaseUtil.checkAdminTenant() ? null:AuthUtil.getTenantId(), |
| | | tableName |
| | | ); |
| | | }else{ |
| | | doList =codeClassifyMapper.selectCodeClassifyVOByTree(treeQueryObject.getParentOid(), AuthUtil.getTenantId().equals(this.tenantId) ? "":AuthUtil.getTenantId()); |
| | | // 只要前端会传参数过来就不会出现走这句的情况,所以查询总数没在这儿添加 |
| | | doList =codeClassifyMapper.selectCodeClassifyVOByTree( |
| | | treeQueryObject.getParentOid(), |
| | | VciBaseUtil.checkAdminTenant() ? null:AuthUtil.getTenantId() |
| | | ); |
| | | } |
| | | List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME); |
| | |
| | | return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" 【停用】 ") : ""); |
| | | }); |
| | | |
| | | Iterator var6 = tree.listIterator(); |
| | | while(var6.hasNext()){ |
| | | Tree trees = (Tree) var6.next(); |
| | |
| | | } |
| | | } |
| | | return tree; |
| | | } |
| | | |
| | | /** |
| | | * 分类加载时获取业务类型id,拼接业务类型表名 |
| | | * @return |
| | | */ |
| | | private String getTableName(String parentCodeClassifyOid,String id,String lcStatus){ |
| | | LambdaQueryWrapper<CodeClassify> wrapper = Wrappers.<CodeClassify>query() |
| | | .lambda().select(CodeClassify::getBtmTypeId) |
| | | .eq(CodeClassify::getLcStatus, lcStatus) |
| | | .isNotNull(CodeClassify::getBtmTypeId) |
| | | .last("limit 1"); |
| | | if(Func.isNotBlank(id)){ |
| | | wrapper.eq(CodeClassify::getId,id).isNull(CodeClassify::getParentCodeClassifyOid); |
| | | }else{ |
| | | wrapper.eq(CodeClassify::getParentCodeClassifyOid,parentCodeClassifyOid); |
| | | } |
| | | CodeClassify codeClassify = codeClassifyMapper.selectOne(wrapper); |
| | | if(Func.isEmpty(codeClassify) || Func.isEmpty(codeClassify.getBtmTypeId())){ |
| | | throw new ServiceException("查询主数据总数时,未获取业务类型ID!"); |
| | | } |
| | | return VciBaseUtil.getTableName(codeClassify.getBtmTypeId(),true); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(StringUtils.isNotBlank(libName)){ |
| | | libNameList=VciBaseUtil.str2List(libName); |
| | | } |
| | | List<CodeClassify> doList =codeClassifyMapper.getRMLibByName(libNameList,"Enabled",AuthUtil.getTenantId()); |
| | | List<CodeClassify> doList =codeClassifyMapper.getRMLibByName(libNameList,"Enabled",AuthUtil.getTenantId() |
| | | .equals( |
| | | NacosConfigCache |
| | | .getAdminUserInfo() |
| | | .getTenantId() |
| | | ) ? null:AuthUtil.getTenantId()); |
| | | List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList); |
| | | return voList; |
| | | } |
| | | |
| | | /*** |
| | | * 根据oid获取下面所有的分类信息 |
| | | * @param oid |
| | | * @return |
| | | */ |
| | | public List<CodeClassifyVO> selectAllClassifyByOid(String oid){ |
| | | List<CodeClassify> codeClassifyList=codeClassifyMapper.selectAllClassifyByOid(oid,AuthUtil.getTenantId()); |
| | | List<CodeClassifyVO> voList = codeClassifyDO2VOs(codeClassifyList); |
| | | return voList; |
| | | |
| | | } |
| | | /*** |
| | | * 根据分类描述备注和库节点查询分类信息 |
| | | * @param desc |
| | |
| | | if(allLevel){ |
| | | List<CodeClassify> classifyDOS = codeClassifyMapper.selectAllLevelChildHasPath(codeClassifyOid,fieldInPath); |
| | | if(!CollectionUtils.isEmpty(classifyDOS)){ |
| | | classifyDOS = classifyDOS.stream().filter(s->FRAMEWORK_DATA_ENABLED.equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList()); |
| | | // 这儿用stream有点慢 |
| | | classifyDOS = classifyDOS.parallelStream().filter(s->FRAMEWORK_DATA_ENABLED.equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList()); |
| | | } |
| | | return codeClassifyDO2VOs(classifyDOS); |
| | | }else{ |
| | |
| | | s -> StringUtils.isNotBlank(s.getCodeRuleId())) |
| | | .map(CodeClassifyPO::getCodeRuleId) |
| | | .collect(Collectors.toList()); |
| | | Map<String, CodeRuleVO> ruleVOMap = Optional.ofNullable(ruleOids.size()==0 ? null:codeRuleService.listCodeRuleByOids(ruleOids) |
| | | Map<String, CodeRuleVO> ruleVOMap = Optional.ofNullable(ruleOids.size()==0 ? null:codeRuleService.listCodeRuleByIds(ruleOids,true) |
| | | ).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t,(o1,o2)->o2)); |
| | | |
| | | List<String> keyOids = poList.stream().filter(s -> StringUtils.isNotBlank(s.getKeyRepeatRuleId())) |
| | |
| | | classifyDO.setBtmname("codeclassify"); |
| | | classifyDO.setLcStatus("Enabled"); |
| | | classifyDO.setOwner(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | classifyDO.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | classifyDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | // classifyDO.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | // classifyDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | classifyDO.setCreator(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | classifyDO.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount())); |
| | | classifyDO.setLastModifyTime(new Date()); |
| | | codeClassifyMapper.insert(classifyDO); |
| | | } |
| | |
| | | List<Map<String,Object>> cbos = codeClassifyMapper.selectAllLevelParentByOid(oid); |
| | | Map<String,String> oidLevelMap = new HashMap<>(); |
| | | Optional.ofNullable(cbos).orElseGet(()->new ArrayList<>()).stream().forEach(cbo->{ |
| | | oidLevelMap.put(cbo.get("OID").toString(),cbo.get("LEVEL").toString()); |
| | | // 用key取map值并且不区分大小写 |
| | | oidLevelMap.put(cbo.getOrDefault("OID",cbo.get("oid")).toString(),cbo.get("LEVEL").toString()); |
| | | }); |
| | | if(CollectionUtils.isEmpty(oidLevelMap)){ |
| | | return new ArrayList<>(); |
| | |
| | | return null; |
| | | } |
| | | List<Tree> treeList = trees.stream().filter(tree -> !CollectionUtils.isEmpty(btmTypeVOS.stream().filter(btmType -> { |
| | | if(Objects.equals(tree.getAttributes().get("id"), btmType.getId())){ |
| | | if(Objects.equals(tree.getAttributes().get("btmTypeId"), btmType.getId())){ |
| | | tree.getAttributes().put("btmTypeOid",btmType.getOid()); |
| | | return true; |
| | | } |