xiejun
2023-07-13 2871cb99e018f6bf9e2ef76a424a1429a7c818f0
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
@@ -117,9 +117,6 @@
      return codeClassifyMapper.selectObjs(wrapper);
   }
   @Override
   public IPage<CodeClassifyVO> selectPlCodeClassifyPage(IPage<CodeClassifyVO> page, CodeClassifyVO plCodeClassify) {
      return page.setRecords(codeClassifyMapper.selectPlCodeClassifyPage(page, plCodeClassify));
@@ -131,11 +128,11 @@
      if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){
         return R.fail("只有在顶层的主题库分类才能设置业务类型");
      }
      codeClassifyEntity.setCreator(AuthUtil.getUser().getUserName());
      codeClassifyEntity.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
      codeClassifyEntity.setCreateTime(new Date());
      codeClassifyEntity.setTs(new Date());
      codeClassifyEntity.setOwner(AuthUtil.getUser().getUserName());
      codeClassifyEntity.setLastModifier(AuthUtil.getUser().getUserName());
      codeClassifyEntity.setOwner(String.valueOf(AuthUtil.getUser().getUserId()));
      codeClassifyEntity.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      codeClassifyEntity.setLastModifyTime(new Date());
      codeClassifyEntity.setRevisionSeq(1);
      codeClassifyEntity.setVersionSeq(1);
@@ -154,20 +151,17 @@
         return R.fail("传入数据不能为空!");
      }
      //检查ts
      Map<String,Object> condition = new HashMap<>(2);
      condition.put("oid",codeClassifyEntity.getOid());
      condition.put("ts",codeClassifyEntity.getTs());
      CodeClassify detail = codeClassifyMapper
         .selectOne(Condition.getQueryWrapper(condition,CodeClassify.class));
      if(detail == null){//不是最新的不让改
      CodeClassify detail = codeClassifyMapper.selectById(codeClassifyEntity.getOid());
      if(!detail.getTs().toString().equals(codeClassifyEntity.getTs().toString())){//不是最新的不让改
         return R.fail("当前数据不是最新,请刷新后再修改!");
      }
      if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){
         return R.fail("只有在顶层的主题库分类才能设置业务类型");
      }
      codeClassifyEntity.setLastModifier(AuthUtil.getUser().getUserName());
      codeClassifyEntity.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      codeClassifyEntity.setLastModifyTime(new Date());
      codeClassifyEntity.setTs(new Date());
      int insertNumber = codeClassifyMapper.updateById(codeClassifyEntity);
//         //处理数据集成逻辑,成功后执行集成第一步,分类数据特殊处理。只有启用状态的分类才推送
@@ -203,8 +197,7 @@
    * @return  数据对象
    */
   private CodeClassify selectByOid(String oid){
      CodeClassify codeClassifyEntity = codeClassifyMapper.selectById(oid.trim());
      CodeClassify codeClassifyEntity = codeClassifyMapper.selectClassifyByKeyAndReseRel("'"+oid.trim()+"'").get(0);
      if(codeClassifyEntity == null || StringUtils.isBlank(codeClassifyEntity.getOid())){
         throw new ServiceException("dataOidNotExist");//根据主键id未查到相关数据
      }
@@ -354,7 +347,7 @@
      codeClassify.setLcStatus(lcStatus);
      codeClassify.setTs(new Date());
      codeClassify.setLastModifyTime(new Date());
      codeClassify.setLastModifier(AuthUtil.getUser().getUserName());
      codeClassify.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
      //启用、停用
//      int u = codeClassifyMapper.updateLcStatus(oid,lcStatus);
      int count = codeClassifyMapper.updateById(codeClassify);
@@ -547,8 +540,11 @@
    */
   @Override
   public List<CodeClassifyVO> getIdPathToNamePathByParentId(String classifyId, boolean enable) {
      return null;
      List<CodeClassify>  doList=   codeClassifyMapper.getIdPathToNamePathByParentId(classifyId);
      List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList);
      return voList;
   }
   //   /**
//    * 根据树形查询对象来查询数据对象
@@ -591,7 +587,7 @@
      codeClassifyVOS.add(codeClassifyVO);
      //查询一下规则的编号,和关键属性重复规则
      List<String> codeRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCoderuleoid())).map(CodeClassifyVO::getCoderuleoid).collect(Collectors.toList());
      List<String> codeRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCodeRuleOid())).map(CodeClassifyVO::getCodeRuleOid).collect(Collectors.toList());
      Map<String, CodeRuleVO> ruleVOMap = new HashMap<>();
      if(!CollectionUtils.isEmpty(codeRuleOids)){
         VciBaseUtil.switchCollectionForOracleIn(codeRuleOids).stream().forEach(ruleOids->{
@@ -601,7 +597,7 @@
         });
      }
      //找关键属性规则
      List<String> keyRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCodekeyattrrepeatoid())).map(CodeClassifyVO::getCodekeyattrrepeatoid).collect(Collectors.toList());
      List<String> keyRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCodeKeyAttrRepeatOid())).map(CodeClassifyVO::getCodeKeyAttrRepeatOid).collect(Collectors.toList());
      Map<String, CodeKeyAttrRepeatRuleVO> keyRuleVOMap = new HashMap<>();
      if(!CollectionUtils.isEmpty(keyRuleOids)){
         VciBaseUtil.switchCollectionForOracleIn(keyRuleOids).stream().forEach(ruleOids->{
@@ -633,12 +629,12 @@
         CodeClassifyVO vo = codeClassifyVOS.get(i);
         excelDataList.add(new WriteExcelData(i+1,0,vo.getId()));
         excelDataList.add(new WriteExcelData(i+1,1,vo.getName()));
         excelDataList.add(new WriteExcelData(i+1,2,vo.getBtmtypeid()));
         excelDataList.add(new WriteExcelData(i+1,3,vo.getBtmtypename()));
         excelDataList.add(new WriteExcelData(i+1,4, StringUtils.isNotBlank(vo.getCoderuleoid())?ruleVOMap.getOrDefault(vo.getCoderuleoid(),new CodeRuleVO()).getId():""));
         excelDataList.add(new WriteExcelData(i+1,5, StringUtils.isNotBlank(vo.getCoderuleoid())?ruleVOMap.getOrDefault(vo.getCoderuleoid(),new CodeRuleVO()).getName():""));
         excelDataList.add(new WriteExcelData(i+1,6, StringUtils.isNotBlank(vo.getCodekeyattrrepeatoid())?keyRuleVOMap.getOrDefault(vo.getCodekeyattrrepeatoid(),new CodeKeyAttrRepeatRuleVO()).getId():""));
         excelDataList.add(new WriteExcelData(i+1,7, StringUtils.isNotBlank(vo.getCodekeyattrrepeatoid())?keyRuleVOMap.getOrDefault(vo.getCodekeyattrrepeatoid(),new CodeKeyAttrRepeatRuleVO()).getName():""));
         excelDataList.add(new WriteExcelData(i+1,2,vo.getBtmTypeId()));
         excelDataList.add(new WriteExcelData(i+1,3,vo.getBtmTypeName()));
         excelDataList.add(new WriteExcelData(i+1,4, StringUtils.isNotBlank(vo.getCodeRuleOid())?ruleVOMap.getOrDefault(vo.getCodeRuleOid(),new CodeRuleVO()).getId():""));
         excelDataList.add(new WriteExcelData(i+1,5, StringUtils.isNotBlank(vo.getCodeRuleOid())?ruleVOMap.getOrDefault(vo.getCodeRuleOid(),new CodeRuleVO()).getName():""));
         excelDataList.add(new WriteExcelData(i+1,6, StringUtils.isNotBlank(vo.getCodeKeyAttrRepeatOid())?keyRuleVOMap.getOrDefault(vo.getCodeKeyAttrRepeatOid(),new CodeKeyAttrRepeatRuleVO()).getId():""));
         excelDataList.add(new WriteExcelData(i+1,7, StringUtils.isNotBlank(vo.getCodeKeyAttrRepeatOid())?keyRuleVOMap.getOrDefault(vo.getCodeKeyAttrRepeatOid(),new CodeKeyAttrRepeatRuleVO()).getName():""));
         excelDataList.add(new WriteExcelData(i+1,8,vo.getOid().equalsIgnoreCase(codeClassify.getOid())?vo.getPath():codeClassify.getPath() + vo.getPath()));
         excelDataList.add(new WriteExcelData(i+1,9,FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())));
         excelDataList.add(new WriteExcelData(i+1,10,vo.getDataLevel()));
@@ -661,7 +657,7 @@
   @Override
   public List<CodeClassifyVO> listChildrenClassify(String codeClassifyOid, boolean allLevel, String fieldInPath, boolean enable) {
      if(allLevel){
         List<CodeClassify> classifyDOS = codeClassifyMapper.selectAllLevelChildHasPath(codeClassifyOid);
         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());
         }
@@ -781,7 +777,7 @@
      Map<String/**路径**/,String/**主键**/> oidPathMap = new HashMap<>();
      //我们需要查询所有已经存在的分类,主要是路径,用来判断分类的数据
      List<CodeClassify> existClassifyDOs = codeClassifyMapper.selectAllLevelChildHasPath("");
      List<CodeClassify> existClassifyDOs = codeClassifyMapper.selectAllLevelChildHasPath("",null);
      Map<String/**路径**/, CodeClassify/**已经存在的数据**/> pathDOMap = Optional.ofNullable(existClassifyDOs).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> {
         String path = s.getPath();
         if(StringUtils.isNotBlank(path) && path.startsWith("#")){
@@ -899,9 +895,9 @@
               classifyDO.setTs(new Date());
               classifyDO.setBtmname("codeclassify");
               classifyDO.setLcStatus("Enabled");
               classifyDO.setOwner(AuthUtil.getUser().getUserName());
               classifyDO.setCreator(AuthUtil.getUser().getUserName());
               classifyDO.setLastModifier(AuthUtil.getUser().getUserName());
               classifyDO.setOwner(String.valueOf(AuthUtil.getUser().getUserId()));
               classifyDO.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
               classifyDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
               classifyDO.setLastModifyTime(new Date());
               codeClassifyMapper.insert(classifyDO);
            }
@@ -936,12 +932,12 @@
         return new DataGrid<>();
      }
      CodeClassifyVO topClassifyVO = getTopClassifyVO(classifyOid);
      if(topClassifyVO == null || StringUtils.isBlank(topClassifyVO.getBtmtypeid())){
      if(topClassifyVO == null || StringUtils.isBlank(topClassifyVO.getBtmTypeId())){
         return new DataGrid<>();
      }
      Map<String,Object> condition = new HashMap<>(1);
      condition.put("pkbtmtype",topClassifyVO.getBtmtypeid());
      condition.put("pkbtmtype",topClassifyVO.getBtmTypeId());
      R<BtmTypeVO> btmTypeDetail = btmTypeClient.getDetail(btmTypeOid);
      if(btmTypeDetail.getCode() != 200){
         throw new ServiceException("业务类型feign接口调用出错");
@@ -971,7 +967,7 @@
            }
         });
      }
      R<BtmTypeVO> btmTypeVOR = btmTypeClient.getDefaultAttrByBtmId(topClassifyVO.getBtmtypeid());
      R<BtmTypeVO> btmTypeVOR = btmTypeClient.getDefaultAttrByBtmId(topClassifyVO.getBtmTypeId());
      if(btmTypeVOR.getCode() != 200){
         throw new ServiceException("业务类型feign接口调用出错");
      }
@@ -1083,10 +1079,10 @@
    */
   @Override
   public CodeClassifyVO getObjectByIdPath(String idPath) {
      List<Map<String, Object>> idPathValues = codeClassifyMapper.selectByFieldPath("/" + idPath);
      List<Map<String, Object>> idPathValues = codeClassifyMapper.selectByFieldPath("#" + idPath);
      CodeClassify classifyDO = null;
      if (idPathValues != null){
         classifyDO = codeClassifyMapper.selectById(idPathValues.get(0).get("oid").toString());
         classifyDO = codeClassifyMapper.selectByIdRel(idPathValues.get(0).get("OID").toString());
      }
      return codeClassifyDO2VO(classifyDO);
   }
@@ -1187,7 +1183,7 @@
      fullInfo.setParentClassifyVOs(codeClassifyDO2VOs(codeClassifyList));
      if(!CollectionUtils.isEmpty(fullInfo.getParentClassifyVOs())){
         fullInfo.setTopClassifyVO(fullInfo.getParentClassifyVOs().stream().filter(s->StringUtils.isBlank(s.getParentcodeclassifyoid())).findFirst().orElseGet(()->null));
         fullInfo.setTopClassifyVO(fullInfo.getParentClassifyVOs().stream().filter(s->StringUtils.isBlank(s.getParentCodeClassifyOid())).findFirst().orElseGet(()->null));
      }
      return fullInfo;
   }