mamc
2023-07-07 dabd11d102b45ad1edc5f14302147a7e4aa6ad58
修复参照列表bug
已修改1个文件
155 ■■■■ 文件已修改
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java 155 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -362,10 +362,10 @@
        // 回收需要业务数据删除
        if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
            R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname()));
            if (!listR.isSuccess() || listR.getData().size() == 0) {
                throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()));
            if (!listR.isSuccess() || listR.getData().size() == 0) {
                throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(), VciBaseUtil.toInSql(baseModelDTO.getOid()));
        } else {
            for (BaseModel baseModel : baseModels) {
                baseModel.setLcStatus(baseModelDTO.getLcStatus());
@@ -646,9 +646,9 @@
//            final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
            R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmtypeid()));
//                String referTable = VciBaseUtil.getTableName(referVO.getReferType());
            if (!listR.isSuccess() || listR.getData().size() == 0) {
                throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            if (!listR.isSuccess() || listR.getData().size() == 0) {
                throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
            }
            final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
            conditionMap.forEach((key, value) -> {
                sql[0] += " and " + key + " = " + value;
@@ -1599,9 +1599,9 @@
                //使用传入的业务类型查询表
                R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referVO.getReferType()));
//                String referTable = VciBaseUtil.getTableName(referVO.getReferType());
                if (!listR.isSuccess() || listR.getData().size() == 0) {
                    throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
                }
                if (!listR.isSuccess() || listR.getData().size() == 0) {
                    throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
                }
                String referTable = listR.getData().get(0).getTableName();
//                String referTable = "pl_code_classify";
                String referTableNick = attrVO.getId() + "0";
@@ -1698,9 +1698,9 @@
        }
//        String tableName = VciBaseUtil.getTableName(btmType);
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
//                String referTable = VciBaseUtil.getTableName(referVO.getReferType());
        String tableName = listR.getData().get(0).getTableName();
        String sql = "select " + selectFieldList.stream().map(s -> (s.contains(".") ? s : ("t." + s))).collect(Collectors.joining(","))
@@ -1875,7 +1875,7 @@
//                    String selectKey = referFieldMap.get(key);
//                    return getSqlByValue(selectKey, value, null, btmType);
//                } else {
                    return getSqlByValue(key, value, attrVOMap, btmType);
                return getSqlByValue(key, value, attrVOMap, btmType);
//                }
            }
        }
@@ -1930,7 +1930,7 @@
            }
            if (field.contains(".") && attrVOMap != null && attrVOMap.containsKey(field.split("\\.")[0].toLowerCase(Locale.ROOT))) {
                //是参照
                return "'" + value + "'";
                return "'" + value + "'";
            } else {
                return value;
            }
@@ -1954,13 +1954,13 @@
                        || VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
                    return value;
                } else {
                    return "'" + value + "'";
                    return "'" + value + "'";
                }
            } else {
                if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
                    return value;
                }
                return "'" + value + "'";
                return "'" + value + "'";
            }
        }
@@ -2239,9 +2239,9 @@
//        baseMapper.deleteBatchIds(cboList);
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getCurrentClassifyVO().getBtmtypeid()));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        commonsMapper.deleteByTaleAndOid(listR.getData().get(0).getTableName(),
                "'" + (StringUtils.join(cboList.stream().map(BaseModel::getOid).collect(Collectors.toSet()), "','")) + "'");
        //        );
@@ -2445,27 +2445,27 @@
     */
    @Override
    public R markDataPassing(String oid, String btmName, Boolean pass) {
        VciBaseUtil.alertNotNull(oid, "业务数据主键", btmName, "业务类型", pass, "标记类型");
        boolean flag = true;
        try {
            List<BaseModel> datas = selectByTypeAndOid(btmName, oid);
            if (datas.size() == 0) {
                return R.fail(DATA_OID_NOT_EXIST);
            }
            datas.stream().forEach(data->data.getData().put("PASSING",String.valueOf(pass)));
            R r = updateBatchByBaseModel(btmName, datas);
            if(!r.isSuccess()){
                flag = false;
            }
        } catch (Exception e) {
            flag = false;
            e.printStackTrace();
        }
        if (flag) {
            return R.success("标记成功!");
        } else {
            return R.fail("标记失败!");
        }
        VciBaseUtil.alertNotNull(oid, "业务数据主键", btmName, "业务类型", pass, "标记类型");
        boolean flag = true;
        try {
            List<BaseModel> datas = selectByTypeAndOid(btmName, oid);
            if (datas.size() == 0) {
                return R.fail(DATA_OID_NOT_EXIST);
            }
            datas.stream().forEach(data -> data.getData().put("PASSING", String.valueOf(pass)));
            R r = updateBatchByBaseModel(btmName, datas);
            if (!r.isSuccess()) {
                flag = false;
            }
        } catch (Exception e) {
            flag = false;
            e.printStackTrace();
        }
        if (flag) {
            return R.success("标记成功!");
        } else {
            return R.fail("标记失败!");
        }
    }
    /**
@@ -2777,18 +2777,18 @@
        }
        List<String> oidList = VciBaseUtil.str2List(conditionMap.get("oid"));
        List<BaseModel> cbos = selectByTypeAndOid(btmType,conditionMap.get("oid"));
        List<BaseModel> cbos = selectByTypeAndOid(btmType, conditionMap.get("oid"));
        if (CollectionUtils.isEmpty(cbos)) {
            throw new VciBaseException("未找到业务数据");
        }
        BaseModel cbo = cbos.get(0);
        BaseModel cbo = cbos.get(0);
        String templateOid = cbo.getData().get("CODETEMPLATEOID");
        QueryWrapper<CodeClassifyTemplate> codeClassifyTemplateWrapper = new QueryWrapper<>();
        codeClassifyTemplateWrapper.eq("oid", templateOid);
        List<CodeClassifyTemplate> templateDOList = templateService.list(codeClassifyTemplateWrapper);
        QueryWrapper<CodeClassifyTemplateAttr> codeClassifyTemplateAttrWrapper = new QueryWrapper<>();
        QueryWrapper<CodeClassifyTemplateAttr> codeClassifyTemplateAttrWrapper = new QueryWrapper<>();
        codeClassifyTemplateAttrWrapper.eq("CLASSIFYTEMPLATEOID", templateOid);
        List<CodeClassifyTemplateAttr> attrDOList = codeClassifyTemplateAttrService.list(codeClassifyTemplateAttrWrapper);
@@ -3176,9 +3176,9 @@
    public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
@@ -3203,9 +3203,9 @@
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //查询数据
        List<Map> maps = commonsMapper.selectBySql("select * from " + listR.getData().get(0).getTableName() + " where oid in ("
                + VciBaseUtil.toInSql(oids.toString()) + ")");
@@ -3261,9 +3261,9 @@
     */
    public BaseModel createBaseModel(String boName) {
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(boName));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        String userName = String.valueOf(AuthUtil.getUser().getUserId());
        BaseModel bo = new BaseModel();
//        bo.setOid(VciBaseUtil.getPk());
@@ -3331,9 +3331,9 @@
    public R updateBatchByBaseModel(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
@@ -3361,17 +3361,17 @@
     * @return 列表数据
     */
    @Override
    public IPage<BaseModel> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) throws VciBaseException{
        //checkReferConfig(referConfigVO);
    public IPage<BaseModel> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) throws VciBaseException {
        //checkReferConfig(referConfigVO);
        //使用业务类型查询
        R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
        if (allAttributeByBtmId.getCode() != 200) {
            throw new ServiceException("业务类型feign接口调用错误!");
        }
        if (Func.isEmpty(allAttributeByBtmId.getData())) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        BtmTypeVO btmTypeVO = allAttributeByBtmId.getData();
        if (allAttributeByBtmId.getCode() != 200) {
            throw new ServiceException("业务类型feign接口调用错误!");
        }
        if (Func.isEmpty(allAttributeByBtmId.getData())) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        BtmTypeVO btmTypeVO = allAttributeByBtmId.getData();
        /**
         * 加上查询最新版次
         */
@@ -3388,10 +3388,10 @@
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referConfigVO.getReferType()));
        if (listR.getCode() != 200) {
            throw new ServiceException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg():"业务类型feign接口调用错误!");
            throw new ServiceException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg() : "业务类型feign接口调用错误!");
        }
        if (listR.getData().isEmpty()) {
            throw new VciBaseException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg():"传入业务类型未查询到相应表单,请检查!");
            throw new VciBaseException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg() : "传入业务类型未查询到相应表单,请检查!");
        }
        String namesql = "";
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
@@ -3411,13 +3411,18 @@
        if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("lcstatus"))) {
            lcstatusSql = "lcstatus =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lcstatus"));
        }
        String where = "";
        if (StringUtils.isNotBlank(codesql) || StringUtils.isNotBlank(lcstatusSql) || StringUtils.isNotBlank(namesql)) {
             where="where ";
        }
        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() + SPACE
                + (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId()) ? (" where lastr = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastr").toString())
                + " and lastv =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and":" where") + SPACE
                + " and lastv =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and": where) + SPACE
                + lcstatusSql + namesql + codesql + ") t where rownum <=" + num1 + ") where rn >=" + num2
        );
        List<BaseModel> baseModels = new ArrayList<>();
@@ -3461,12 +3466,12 @@
        }
        int total = commonsMapper.queryCountBySql("select count(*) from " + listR.getData().get(0).getTableName() + SPACE
                + (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId()) ? (" where lastr = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastr").toString())
                + "and lastv = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and":" where") + SPACE
                + "and lastv = " + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lastv").toString())) + " and" : where) + SPACE
                + lcstatusSql + namesql + codesql
        );
        IPage<BaseModel> objectDataGrid = new Page<>();
        IPage<BaseModel> objectDataGrid = new Page<>();
        objectDataGrid.setPages(baseQueryObject.getPage());
        objectDataGrid.setCurrent(baseQueryObject.getPage());
        objectDataGrid.setCurrent(baseQueryObject.getPage());
        objectDataGrid.setRecords(baseModels);
        objectDataGrid.setSize(baseQueryObject.getLimit());
        objectDataGrid.setTotal(total);
@@ -3598,10 +3603,10 @@
        toBo.setVersionRule(fromBo.getVersionRule());
//        RevisionValueObject rvObj = this.getNextRevision(fromBo.getBtmName(), fromBo.getNameoid(), item.revRuleName, item.revInput, revisionVal);
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(fromBo.getBtmname()));
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
        if (!listR.isSuccess() || listR.getData().size() == 0) {
            throw new VciBaseException("传入业务类型未查询到相应表单,请检查!");
        }
        Map<String, Object> nextRevision = commonsMapper.getNextRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
        toBo.setRevisionSeq(Integer.parseInt(nextRevision.get("REVISIONSEQ").toString()));
        toBo.setRevisionValue(nextRevision.get("REVISIONVAL").toString());
//        VersionValueObject versionObj = this.getVersionValue(item.verRuleName);