1428594221
2023-06-27 35ad24a24e91e1996ef9e97c2714bfbc7a32cdfa
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -148,7 +148,6 @@
   ICodeReferBtmTypeService codeReferBtmTypeService;
   /**
    * 相似项查询规则
    */
@@ -282,7 +281,6 @@
   public static final String SPECIAL_CHAR = "VCI";
//   @Autowired
//   private CodeOsbtmtypeMapper codeOsbtmtypeMapper;----
   /**
@@ -857,6 +855,7 @@
   /**
    * 初始化业务类型
    * --创建人默认为当前用户,如果需要修改,可以在获取后自行处理
     *
    * @param btmName 业务类型的名称,会自动变成小写
    * @return CodeWupinEntity
    * @throws VciBaseException 初始化出错的是会抛出异常
@@ -880,7 +879,6 @@
         throw new VciBaseException("initBtmError",new String[]{btmName});
      }
   }
   /**
@@ -1010,6 +1008,7 @@
      //查询是否有分类注入的
      return formDefineVO;
   }
   /**
    * 属性类型与js中的字段类型的映射
    */
@@ -1962,6 +1961,7 @@
   /**
    * 查看是否默认属性
     *
    * @param selectKey
    * @param btmType
    * @return
@@ -2747,6 +2747,7 @@
      }
      return VciBaseUtil.str2List(tempAttrOidArr.get(0).get("codetempattroidarr").toString());
   }
   /**
    * 使用分类的主键获取业务数据
    *
@@ -2828,6 +2829,7 @@
         return null;
      }
   }
   /**
    * 使用分类的主键获取表格的定义
    *
@@ -2944,6 +2946,7 @@
   /**
    * 加载成参照的修改配置
     *
    * @param vo 表格字段显示对象
    */
   private void setReferConfig2EditConfig(UITableFieldVO vo) {
@@ -2974,6 +2977,7 @@
   /**
    * 加载成下拉框的修改配置
     *
    * @param vo 表格字段显示对象
    */
   private void setComboxConfig2EditConfig(UITableFieldVO vo) {
@@ -3261,6 +3265,7 @@
   /**
    * 根据业务类型名称创建业务数据源对象
     *
    * @param boName 业务类型名称
    * @return 业务数据对象
    */
@@ -3307,6 +3312,7 @@
   /**
    * 获取版次的值
     *
    * @param verRuleName 版次的规则
    * @return 版次的值,没有规则则为空
    */
@@ -3362,7 +3368,7 @@
    * @return 列表数据
    */
   @Override
   public Page<BtmTypeVO> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) {
    public DataGrid<BaseModel> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) {
//      checkReferConfig(referConfigVO);
      //使用业务类型查询
      R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
@@ -3380,12 +3386,95 @@
         BtmTypeLcStatusConstant.RELEASE_LIFE_CYCLE.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
         baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, CodeDefaultLC.RELEASED.getValue());
      }
      baseQueryObject.getConditionMap().put("domain", AppConstant.APPLICATION_NAME_CODE);
      R<Page<BtmTypeVO>> refPage = btmTypeClient.getRefPage(baseQueryObject);
      if(refPage.getCode() != 200){
         throw new ServiceException("业务类型feign接口调用错误");
//        baseQueryObject.getConditionMap().put("domain", AppConstant.APPLICATION_NAME_CODE);
//        R<Page<BtmTypeVO>> refPage = btmTypeClient.getRefPage(baseQueryObject);
//
//        if (refPage.getCode() != 200) {
//            throw new ServiceException("业务类型feign接口调用错误");
//        }
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referConfigVO.getReferType()));
        if (listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
      }
      return refPage.getData();
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
            String s = baseQueryObject.getConditionMap().get("name");
            s = "%" + s + "%";
            namesql = "and name like" + VciBaseUtil.toInSql(s);
        }
        String codesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("id"))) {
            String s = baseQueryObject.getConditionMap().get("id");
            s = "%" + s + "%";
            codesql = "and id like" + VciBaseUtil.toInSql(s);
        }
        String lcstatusSql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("lcstatus"))) {
            lcstatusSql = "and lcstatus =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lcstatus"));
        }
        String num1 = baseQueryObject.getPage() * baseQueryObject.getLimit() + "";
        String num2 = ((baseQueryObject.getPage()) - 1) * baseQueryObject.getLimit() + 1 + "";
        List<Map> maps = commonsMapper.selectBySql("select * from ( select rownum rn, t.* from (select * from " + listR.getData().get(0).getTableName()
                + " where lastr = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastr").toString())
                + "and lastv =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())
                + lcstatusSql + namesql + codesql + ") t where rownum <=" + num1 + ") where rn >=" + num2
        );
        List<BaseModel> baseModels = new ArrayList<>();
        //将查询到的数据转换为basemodel,使用的反射方式来进行创建的
        try {
            for (Map map : maps) {
                Object obj = BaseModel.class.newInstance();
                BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
                for (PropertyDescriptor property : propertyDescriptors) {
                    Method setter = property.getWriteMethod();
                    if (setter != null) {
                        //oracle的时间为TIMESTAMP的,需要进行转换成data,否则将报错
                        if (map.get(property.getName().toUpperCase()) instanceof TIMESTAMP) {
                            LocalDateTime localDateTime = ((TIMESTAMP) map.get(property.getName().toUpperCase())).toLocalDateTime();
                            ZoneId zoneId = ZoneId.systemDefault();
                            ZonedDateTime zdt = localDateTime.atZone(zoneId);
                            Date date = Date.from(zdt.toInstant());
                            setter.invoke(obj, date);
                            map.remove(property.getName().toUpperCase());
                        } //oracle的数字为BigDecimal的,需要进行转换成Integer,否则将报错
                        else if (map.get(property.getName().toUpperCase()) instanceof BigDecimal
                                && ("Integer").equals(setter.getParameterTypes()[0].getSimpleName())) {
                            setter.invoke(obj, ((BigDecimal) map.get(property.getName().toUpperCase())).intValue());
                            map.remove(property.getName().toUpperCase());
                        } else if (map.get(property.getName().toUpperCase()) != null) {
                            setter.invoke(obj, map.get(property.getName().toUpperCase()));
                            map.remove(property.getName().toUpperCase());
                        }
                    }
                }
                for (Object key : map.keySet()) {
                    map.put(key, String.valueOf(map.get(key)));
                }
                ((BaseModel) obj).setData(map);
                baseModels.add((BaseModel) obj);
            }
        } catch (Exception e) {
            throw new VciBaseException("查询失败:" + e.getMessage());
        }
        int total = commonsMapper.queryCountBySql("select count(*) from " + listR.getData().get(0).getTableName()
                + " where lastr = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastr").toString())
                + "and lastv =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())
                + lcstatusSql + namesql + codesql
        );
        DataGrid<BaseModel> objectDataGrid = new DataGrid<>();
        objectDataGrid.setPage(baseQueryObject.getPage());
        objectDataGrid.setData(baseModels);
        objectDataGrid.setLimit(baseQueryObject.getLimit());
        objectDataGrid.setTotal(total);
        return objectDataGrid;
   }
   /**