xiejun
2023-06-16 2f3ddd502ceda48df79c63b3c0b5654585a04ddf
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/UniversalInterfaceImpl.java
@@ -9,6 +9,7 @@
import com.vci.ubcs.code.dto.CodeOrderDTO;
import com.vci.ubcs.code.dto.CodeOrderSecDTO;
import com.vci.ubcs.code.entity.*;
import com.vci.ubcs.code.enumpack.CodeDefaultLC;
import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
import com.vci.ubcs.code.mapper.CommonsMapper;
import com.vci.ubcs.code.service.*;
@@ -29,6 +30,7 @@
import com.vci.ubcs.code.wrapper.CodeClassifyWrapper;
import com.vci.ubcs.omd.feign.IBtmTypeClient;
import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.starter.revision.model.BaseModel;
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.web.constant.QueryOptionConstant;
@@ -591,73 +593,112 @@
         String classCode=condtionVO.getClassCode();
         String library= condtionVO.getLibrary();
         String queryFileds= condtionVO.getQueryFileds();
         if(StringUtils.isBlank(library)){
            errorid = "101";
            msg = "接口参数:library 为null";
            throw new Throwable(msg);
         }
         List<CodeClassifyVO> codeClassifyVOS =new ArrayList<>();
         //先简称是否有关联模板,有模板要先删除
         List<CodeClassify> libIdDos =classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId,VciBaseUtil.toInSql(classCode)));
         List<CodeClassify> libIdDos =classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId,library));
         if(!CollectionUtils.isEmpty(libIdDos)){
            CodeClassify currentCodeClassify=libIdDos.get(0);
            String oid=currentCodeClassify.getOid();
            TreeQueryObject treeQueryObject=new TreeQueryObject();
            treeQueryObject.setParentOid(oid);
            treeQueryObject.setQueryAllLevel(true);
            codeClassifyVOS=classifyService.selectCodeClassifyDOByTree(treeQueryObject);
            codeClassifyVOS.add(CodeClassifyWrapper.build().entityVO(currentCodeClassify));
            Map<String, CodeClassifyVO> oidCodeclassifyDOMap = codeClassifyVOS.stream().filter(systeDataObject -> systeDataObject != null && StringUtils.isNotBlank(systeDataObject.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
            List<PropertyVO>  propertyVOS=condtionVO.getPro();
            Map<String,String> condtionMap=new HashMap<>();
            propertyVOS.stream().forEach(propertyVO -> {
               condtionMap.put(propertyVO.getFiledName(),propertyVO.getFiledValue());
            });
            condtionMap.put("codeclsfid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidCodeclassifyDOMap.keySet().toArray(new String[0])) + ")");
            R<BtmTypeVO> r= btmTypeClient.getDetail(library);
            BtmTypeVO btmTypeVO =r.getData();
            String tableName=btmTypeVO.getTableName();
            StringBuffer sb=new StringBuffer();
            sb.append(" select * from ");
            sb.append(tableName);
            sb.append(" where 1=1 ");
            sb.append(" id in (");
            sb.append( VciBaseUtil.toInSql(oidCodeclassifyDOMap.keySet().toArray(new String[0])) );
            sb.append(")");
            List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap( sb.toString());
            List<ClientBusinessObject> clientBusinessObjects=ChangeMapTOClientBusinessObjects(dataMapList);
            List<com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO> dataObjectVOS=new ArrayList<>();
            if(!CollectionUtils.isEmpty(clientBusinessObjects)){
               CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(currentCodeClassify.getOid());
               Map<String, CodeClassifyTemplateAttrVO> filedAttributeMap = templateVO.getAttributes().stream().filter(attribute -> attribute != null && StringUtils.isNotBlank(attribute.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t));
               clientBusinessObjects.stream().forEach(cbo -> {
                  com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO dataObjectVO=new com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO();
                  dataObjectVO.setCode(cbo.getId());
                  dataObjectVO.setStatus(cbo.getLcStatus());
                  String codeclsfid=cbo.getAttributeValue("codeclsfid");
                  if(oidCodeclassifyDOMap.containsKey(codeclsfid)){
                     CodeClassifyVO classifyVO=  oidCodeclassifyDOMap.get(codeclsfid);
                     dataObjectVO.setClassCode(classifyVO.getId());
            CodeClassify libCodeClassify=libIdDos.get(0);
            List<CodeClassify> codeClassifyList=classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId,classCode));
            if(!CollectionUtils.isEmpty(codeClassifyList)){
               final CodeClassify[] currentCodeClassify = {null};
               codeClassifyList.stream().forEach(codeClassify -> {
                  CodeClassifyVO codeClassifyVO=  classifyService.getTopClassifyVO(codeClassify.getOid());
                  if(codeClassifyVO.getOid().equals(libCodeClassify.getOid())){
                     currentCodeClassify[0] =codeClassify;
                  }
                  dataObjectVO.setLibrary(library);
                  String [] newQueryFileds=queryFileds.split(",");
                  List<PropertyVO> propertyVOList=new ArrayList<>();
                  for(String filed:newQueryFileds){
                     String value=cbo.getAttributeValue(filed);
                     if(filedAttributeMap.containsKey(filed)){
                        CodeClassifyTemplateAttrVO attrVO=  filedAttributeMap.get(filed);
                        PropertyVO propertyVO=new PropertyVO();
                        propertyVO.setFiledName(filed);
                        propertyVO.setFiledValue(value);
                        propertyVO.setOutname(attrVO.getName());
                        propertyVOList.add(propertyVO);
                     }
                  }
                  dataObjectVO.setPro(propertyVOList);
                  dataObjectVOS.add(dataObjectVO);
               });
               resultDataVO.setObject(dataObjectVOS);
               if(currentCodeClassify[0]==null){
                  errorid = "101";
                  msg = "接口参数:classCode 未查询到对应的分类信息";
                  throw new Throwable(msg);
               }
               List<CodeClassifyVO> dataCodeClassifyVOList =new ArrayList<>();
               String oid= currentCodeClassify[0].getOid();
               TreeQueryObject treeQueryObject=new TreeQueryObject();
               treeQueryObject.setParentOid(oid);
               treeQueryObject.setQueryAllLevel(true);
               dataCodeClassifyVOList=classifyService.selectCodeClassifyDOByTree(treeQueryObject);
               dataCodeClassifyVOList.add(CodeClassifyWrapper.build().entityVO(currentCodeClassify[0]));
               Map<String, CodeClassifyVO> oidCodeclassifyDOMap = dataCodeClassifyVOList.stream().filter(systeDataObject -> systeDataObject != null && StringUtils.isNotBlank(systeDataObject.getOid())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t));
               List<PropertyVO>  propertyVOS=condtionVO.getPro();
               /*Map<String,String> condtionMap=new HashMap<>();
               propertyVOS.stream().forEach(propertyVO -> {
                  condtionMap.put(propertyVO.getFiledName(),propertyVO.getFiledValue());
               });
               condtionMap.put("codeclsfid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidCodeclassifyDOMap.keySet().toArray(new String[0])) + ")");
               List<String>statusList=new ArrayList<>();
               statusList.add(CodeDefaultLC.RELEASED.getValue());
               statusList.add(CodeDefaultLC.DISABLE.getValue());
               statusList.add(CodeDefaultLC.TASK_BACK.getValue());
               condtionMap.put("Lcstatus",  QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(statusList.toArray(new String[]{})) + ")" );
               condtionMap.put("islastr", "1");
               condtionMap.put("islastv", "1");*/
               List<String>statusList=new ArrayList<>();
               statusList.add(CodeDefaultLC.RELEASED.getValue());
               statusList.add(CodeDefaultLC.DISABLE.getValue());
               statusList.add(CodeDefaultLC.TASK_BACK.getValue());
               R<BtmTypeVO>  r= btmTypeClient.getDetail(libCodeClassify.getBtmTypeId());
               BtmTypeVO btmTypeVO =r.getData();
               String tableName=btmTypeVO.getTableName();
               StringBuffer sb=new StringBuffer();
               sb.append(" select * from  ");
               sb.append(tableName);
               sb.append(" where 1=1");
               propertyVOS.stream().forEach(propertyVO -> {
                  sb.append( " and  "+propertyVO.getFiledName()+"='"+propertyVO.getFiledValue()+"'");
               });
               sb.append(" and islastr=1 and islastv=1" );
               sb.append(" and codeclsfid in (" + VciBaseUtil.toInSql(oidCodeclassifyDOMap.keySet().toArray(new String[0])) +")");
               sb.append(" and Lcstatus in (" + VciBaseUtil.toInSql(statusList.toArray(new String[]{})) +")");
               List<Map<String,String>>  newDataList= commonsMapper.queryByOnlySqlForMap(sb.toString());
               List<ClientBusinessObject>clientBusinessObjects=new ArrayList<>();
               newDataList.stream().forEach(stringStringMap -> {
                  ClientBusinessObject clientBusinessObject=new ClientBusinessObject();
                  DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,clientBusinessObject);
                  clientBusinessObjects.add(clientBusinessObject);
               });
               List<com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO> dataObjectVOS=new ArrayList<>();
               if(!CollectionUtils.isEmpty(clientBusinessObjects)){
                  CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(currentCodeClassify[0].getOid());
                  Map<String, CodeClassifyTemplateAttrVO> filedAttributeMap = templateVO.getAttributes().stream().filter(attribute -> attribute != null && StringUtils.isNotBlank(attribute.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t));
                  clientBusinessObjects.stream().forEach(cbo -> {
                     com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO dataObjectVO=new com.vci.ubcs.code.vo.webserviceModel.data.DataObjectVO();
                     dataObjectVO.setCode(cbo.getId());
                     dataObjectVO.setStatus(cbo.getLcStatus());
                     String codeclsfid=cbo.getAttributeValue("codeclsfid");
                     if(oidCodeclassifyDOMap.containsKey(codeclsfid)){
                        CodeClassifyVO codeClassifyVO=  oidCodeclassifyDOMap.get(codeclsfid);
                        dataObjectVO.setClassCode(codeClassifyVO.getId());
                     }
                     dataObjectVO.setLibrary(library);
                     String [] newQueryFileds=queryFileds.split(",");
                     List<PropertyVO> propertyVOList=new ArrayList<>();
                     for(String filed:newQueryFileds){
                        String value=cbo.getAttributeValue(filed);
                        if(filedAttributeMap.containsKey(filed)){
                           CodeClassifyTemplateAttrVO attrVO=  filedAttributeMap.get(filed);
                           PropertyVO propertyVO=new PropertyVO();
                           propertyVO.setFiledName(filed);
                           propertyVO.setFiledValue(value);
                           propertyVO.setOutname(attrVO.getName());
                           propertyVOList.add(propertyVO);
                        }
                     }
                     dataObjectVO.setPro(propertyVOList);
                     dataObjectVOS.add(dataObjectVO);
                  });
                  resultDataVO.setObject(dataObjectVOS);
               }
            }
         }
         errorid = "0";
@@ -690,6 +731,8 @@
      return resultStr;
   }
   @Override
   public String queryClassifyRule(String data, String dataType) throws Throwable {