From 7940638999efcd69372365e6b6c848f118c70bf2 Mon Sep 17 00:00:00 2001
From: yuxc <653031404@qq.com>
Date: 星期三, 05 七月 2023 17:52:09 +0800
Subject: [PATCH] 1、主要对null整形返回-1进行更改。 2、对获取业务类型表为空进行了判断。

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |  119 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 70 insertions(+), 49 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
index efa0cdc..3f5a5a3 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -1,8 +1,10 @@
 package com.vci.ubcs.code.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
@@ -55,7 +57,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springblade.core.cache.utils.CacheUtil;
-import org.springblade.core.launch.constant.AppConstant;
 import com.vci.ubcs.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -364,7 +365,10 @@
         // 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄�
         if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
             R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname()));
-            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());
@@ -645,6 +649,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("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+			}
             final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
             conditionMap.forEach((key, value) -> {
                 sql[0] += " and " + key + " = " + value;
@@ -1220,7 +1227,8 @@
             fieldVO.setTemplet(attrVO.getTableDisplayJs());
         }
         if (StringUtils.isBlank(fieldVO.getTemplet()) && VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())) {
-            fieldVO.setTemplet("function(d){return $webUtil.formateBoolean(d." + fieldVO.getField() + ");}");
+            fieldVO.setTemplet("function(row,column){return row[column.property]=='true' || row[column.property]=='1'?'鏄�':'鍚�'}");
+//            fieldVO.setTemplet("function(d){return $webUtil.formateBoolean(d." + fieldVO.getField() + ");}");
         }
         fieldVO.setOptionJsMap(eventJsMap);
         fieldVO.setStyle(attrVO.getTableDisplayStyle());
@@ -1579,7 +1587,7 @@
         List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
                 s -> StringUtils.isNotBlank(s.getReferBtmId()) || StringUtils.isNotBlank(s.getReferConfig())
         ).collect(Collectors.toList());
-        Map<String/**鍙傜収鐨勫睘鎬�**/, String/**瀹為檯鐨勫瓧娈�**/> referFieldMap = new HashMap<>();
+        Map<String/**鍙傜収鐨勫睘鎬�**/, String/**瀹為檯鐨勫瓧娈�**/> referFieldMap = new ConcurrentHashMap<>();
         if (!CollectionUtils.isEmpty(referAttrVOs)) {
             referAttrVOs.parallelStream().forEach(attrVO -> {
                 UIFormReferVO referVO = null;
@@ -1594,6 +1602,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("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+				}
                 String referTable = listR.getData().get(0).getTableName();
 //				String referTable = "pl_code_classify";
                 String referTableNick = attrVO.getId() + "0";
@@ -1612,11 +1623,7 @@
             });
         }
         R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getDefaultAttrByBtmId(btmType);
-//		Optional.ofNullable(allAttributeByBtmId.getData()).orElseGet(allAttributeByBtmId.getData().getAttributes()).stream().forEach(attrId -> {
-//			if (!selectFieldList.contains(attrId.getOid()) && !"secretgrade".equalsIgnoreCase(attrId.getOid())) {
-//				selectFieldList.add(attrId.getOid());
-//			}
-//		});
+
         if (allAttributeByBtmId.getData() != null) {
             for (BtmTypeAttributeVO attribute : allAttributeByBtmId.getData().getAttributes()) {
                 if (!selectFieldList.contains(attribute.getId()) && !"secretgrade".equalsIgnoreCase(attribute.getId())) {
@@ -1694,6 +1701,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("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+		}
 //				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(","))
@@ -1863,13 +1873,13 @@
                     return (field.contains(".") ? "" : "t.") + field + SPACE + "= '" + getStringValueInWhere(field, value, attrVOMap) + "'" + SPACE;
                 }
             } else {
-                if (referFieldMap.containsKey(key)) {
-                    //璇存槑鏄弬鐓х殑锛屾垜浠弬鐓х殑鏌ヨ閮借涓烘槸瀛楃涓诧紝濡傛灉鏄椂闂存牸寮忕殑鏌ヨ鑲畾鏈夐棶棰橈紝
-                    String selectKey = referFieldMap.get(key);
-                    return getSqlByValue(selectKey, value, null, btmType);
-                } else {
+//                if (referFieldMap.containsKey(key)) {
+//                    //璇存槑鏄弬鐓х殑锛屾垜浠弬鐓х殑鏌ヨ閮借涓烘槸瀛楃涓诧紝濡傛灉鏄椂闂存牸寮忕殑鏌ヨ鑲畾鏈夐棶棰橈紝
+//                    String selectKey = referFieldMap.get(key);
+//                    return getSqlByValue(selectKey, value, null, btmType);
+//                } else {
                     return getSqlByValue(key, value, attrVOMap, btmType);
-                }
+//                }
             }
         }
         return "";
@@ -1923,7 +1933,7 @@
             }
             if (field.contains(".") && attrVOMap != null && attrVOMap.containsKey(field.split("\\.")[0].toLowerCase(Locale.ROOT))) {
                 //鏄弬鐓�
-                return value;
+				return "'" + value + "'";
             } else {
                 return value;
             }
@@ -1947,13 +1957,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 + "'";
             }
         }
 
@@ -2077,9 +2087,7 @@
                     .append(SPACE)
                     .append(QueryOptionConstant.EQUAL)
                     .append(SPACE)
-					.append("'")
-                    .append(value)
-					.append("'");
+                    .append(value);
         }
         sql.append(SPACE);
         return sql.toString();
@@ -2234,9 +2242,9 @@
 //		baseMapper.deleteBatchIds(cboList);
         //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getCurrentClassifyVO().getBtmtypeid()));
-        if (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()), "','")) + "'");
         //		);
@@ -3171,9 +3179,9 @@
     public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) {
         //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
-        if (listR.getData().size() == 0) {
-            throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
-        }
+		if (!listR.isSuccess() || listR.getData().size() == 0) {
+			throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+		}
         //灏哹ean杞负map,mybatis缁熶竴澶勭悊
         List<Map<String, String>> maps = new ArrayList<>();
         baseModels.stream().forEach(model -> {
@@ -3198,9 +3206,9 @@
 
         //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
-        if (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()) + ")");
@@ -3256,6 +3264,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("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+		}
         String userName = String.valueOf(AuthUtil.getUser().getUserId());
         BaseModel bo = new BaseModel();
 //		bo.setOid(VciBaseUtil.getPk());
@@ -3323,9 +3334,9 @@
     public R updateBatchByBaseModel(String btmType, List<BaseModel> baseModels) {
         //浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
-        if (listR.getData().size() == 0) {
-            throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
-        }
+		if (!listR.isSuccess() || listR.getData().size() == 0) {
+			throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+		}
         //灏哹ean杞负map,mybatis缁熶竴澶勭悊
         List<Map<String, String>> maps = new ArrayList<>();
 
@@ -3353,8 +3364,8 @@
      * @return 鍒楄〃鏁版嵁
      */
     @Override
-    public Page<BaseModel>referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) {
-//		checkReferConfig(referConfigVO);
+    public IPage<BaseModel> referDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject) throws VciBaseException{
+		//checkReferConfig(referConfigVO);
         //浣跨敤涓氬姟绫诲瀷鏌ヨ
         R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
         BtmTypeVO btmTypeVO = allAttributeByBtmId.getData();
@@ -3371,9 +3382,13 @@
                 BtmTypeLcStatusConstant.RELEASE_LIFE_CYCLE.equalsIgnoreCase(btmTypeVO.getLifeCycleId())) {
             baseQueryObject.getConditionMap().put(VciQueryWrapperForDO.LC_STATUS_FIELD, CodeDefaultLC.RELEASED.getValue());
         }
+
         R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referConfigVO.getReferType()));
-        if (listR.getData().size() == 0) {
-            throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+        if (listR.getCode() != 200) {
+            throw new ServiceException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg():"涓氬姟绫诲瀷feign鎺ュ彛璋冪敤閿欒锛�");
+        }
+        if (listR.getData().isEmpty()) {
+            throw new VciBaseException(Func.isNotBlank(listR.getMsg()) ? listR.getMsg():"浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
         }
         String namesql = "";
         if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
@@ -3391,15 +3406,15 @@
 
         String lcstatusSql = "";
         if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("lcstatus"))) {
-            lcstatusSql = "and lcstatus =" + VciBaseUtil.toInSql(baseQueryObject.getConditionMap().get("lcstatus"));
+            lcstatusSql = "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())
+        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
                 + lcstatusSql + namesql + codesql + ") t where rownum <=" + num1 + ") where rn >=" + num2
         );
         List<BaseModel> baseModels = new ArrayList<>();
@@ -3441,15 +3456,18 @@
         } 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())
+        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
                 + lcstatusSql + namesql + codesql
         );
-        Page<BaseModel>page=new Page<>();
-        page.setRecords(baseModels);
-        page.setTotal(total);
-        return page;
+		IPage<BaseModel> objectDataGrid = new Page<>();
+        objectDataGrid.setPages(baseQueryObject.getPage());
+		objectDataGrid.setCurrent(baseQueryObject.getPage());
+        objectDataGrid.setRecords(baseModels);
+        objectDataGrid.setSize(baseQueryObject.getLimit());
+        objectDataGrid.setTotal(total);
+        return objectDataGrid;
     }
 
     /**
@@ -3577,7 +3595,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()));
-        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);

--
Gitblit v1.9.3