1、主要解决在批量插入的时候通过业务类型去获取字段信息,对比字段没有的则不进行插入。
已修改3个文件
40 ■■■■ 文件已修改
Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java
@@ -1294,7 +1294,7 @@
     * @return Map对象
     * @version 2016年3月20日 11:03:01
     */
    public static Map convertBean2Map(Object bean) throws Exception {
    public static Map convertBean2Map(Object bean,Set<String> existFild) throws Exception {
        Class type = bean.getClass();
        Map returnMap = new HashMap();
        BeanInfo beanInfo = Introspector.getBeanInfo(type);
@@ -1332,7 +1332,16 @@
                if (result != null) {
                    if ("data".equals(propertyName)){
                        returnMap.putAll((Map) result);
                        if(existFild == null){
                            returnMap.putAll((Map) result);
                        }else{
                            Map resulMap = (Map) result;
                            for (Object o : resulMap.keySet()) {
                                if(existFild.contains(o)){
                                    returnMap.put(o,resulMap.get(o));
                                }
                            }
                        }
                    }else {
                        returnMap.put(fieldMap.containsKey(propertyName)?fieldMap.get(propertyName):propertyName, result);
                    }
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -400,7 +400,6 @@
    public String addSaveCode(CodeOrderDTO orderDTO) throws Exception {
        VciBaseUtil.alertNotNull(orderDTO, "编码申请相关的属性和码段的内容都为空", orderDTO.getCodeClassifyOid(), "主题库分类的主键",
                orderDTO.getTemplateOid(), "模板的主键", orderDTO.getCodeRuleOid(), "编码规则的主键");
        VciSystemVarConstants.getSystemVarValueMap();
        CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
        CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
        CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid());
@@ -918,7 +917,7 @@
//                        baseModels.stream().forEach(model-> {
                        try {
                            map = VciBaseUtil.convertBean2Map(cbo);
                            map = VciBaseUtil.convertBean2Map(cbo,null);
                        } catch (Exception e) {
                            throw new VciBaseException("类型转换错误:" + e.getMessage());
                        }
@@ -3254,11 +3253,19 @@
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //将bean转为map,mybatis统一处理
        //获取当前业务类型所有字段用来做对比
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType);
        if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应字段信息,请检查!");
        }
        Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
            return btmTypeAttributeVO.getId();
        }).collect(Collectors.toSet());
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model));
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));
            } catch (Exception e) {
                throw new VciBaseException("类型转换错误:" + e.toString());
            }
@@ -3409,12 +3416,20 @@
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //获取当前业务类型所有字段用来做对比
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType);
        if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应字段信息,请检查!");
        }
        Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
            return btmTypeAttributeVO.getId();
        }).collect(Collectors.toSet());
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model));
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));
            } catch (Exception e) {
                throw new VciBaseException("类型转换错误:" + e.getMessage());
            }
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmProductCodeServiceImpl.java
@@ -789,7 +789,7 @@
    private String getValueByFormulaForCBO(BaseModel cbo,String rule)  {
        Map<String, Object> dataMap = null;
        try{
            dataMap = VciBaseUtil.convertBean2Map(cbo);
            dataMap = VciBaseUtil.convertBean2Map(cbo,null);
        }catch(Exception e){
            throw new VciBaseException("mapToBeanError:"+e);
        }