From 1bccfb0296202ecde9c59fd8a16c3d198210319c Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 03 七月 2023 18:53:27 +0800
Subject: [PATCH] 依赖修改,部分不兼容关键字修改,SQL、

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |   61 ++++++++++++++++--------------
 1 files changed, 32 insertions(+), 29 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 55fac7f..0606604 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
@@ -3,6 +3,7 @@
 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,6 +56,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springblade.core.cache.utils.CacheUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.DateUtil;
@@ -1577,7 +1579,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;
@@ -1610,11 +1612,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())) {
@@ -1861,13 +1859,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 "";
@@ -1921,7 +1919,7 @@
             }
             if (field.contains(".") && attrVOMap != null && attrVOMap.containsKey(field.split("\\.")[0].toLowerCase(Locale.ROOT))) {
                 //鏄弬鐓�
-                return value;
+				return "'" + value + "'";
             } else {
                 return value;
             }
@@ -1945,13 +1943,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 + "'";
             }
         }
 
@@ -2075,9 +2073,7 @@
                     .append(SPACE)
                     .append(QueryOptionConstant.EQUAL)
                     .append(SPACE)
-					//.append("'")
                     .append(value);
-				//	.append("'");
         }
         sql.append(SPACE);
         return sql.toString();
@@ -3351,8 +3347,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();
@@ -3369,7 +3365,11 @@
                 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.getCode() != 200) {
+            throw new ServiceException("涓氬姟绫诲瀷feign鎺ュ彛璋冪敤閿欒");
+        }
         if (listR.getData().size() == 0) {
             throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
         }
@@ -3389,15 +3389,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())):"")
                 + lcstatusSql + namesql + codesql + ") t where rownum <=" + num1 + ") where rn >=" + num2
         );
         List<BaseModel> baseModels = new ArrayList<>();
@@ -3440,14 +3440,17 @@
             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())
+                + (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())):"")
                 + 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;
     }
 
     /**

--
Gitblit v1.9.3