From b28da4c353e50fc2491c733889fef5f79e5926f2 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期四, 24 八月 2023 16:19:00 +0800 Subject: [PATCH] 关于集成配置需求更改 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 76 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 72 insertions(+), 4 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 e3cfd10..6b46856 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 @@ -665,7 +665,11 @@ } final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "}; conditionMap.forEach((key, value) -> { - sql[0] += " and " + key + " = " + value; + if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) { + sql[0] += " and " + key + " is null"; + }else{ + sql[0] += " and " + key + " = " + value; + } }); if (StringUtils.isNotBlank(orderDTO.getOid())) { //淇敼鐨勬椂鍊欙紝闇�瑕佹帓闄よ嚜宸� @@ -682,6 +686,66 @@ } } } + + /** + * 鏍¢獙鍏抽敭灞炴�� + * + * @param orderDTO 缂栫爜鐢宠鐨勭浉鍏崇殑淇℃伅 + */ + public List<Map> checkKeyAttrOnOrderFordatas(CodeOrderDTO orderDTO) { + List<Map>dataList=new ArrayList<>(); + CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); + CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); + //鍏堣幏鍙栧叧閿睘鎬х殑瑙勫垯锛屼篃鍒╃敤缁ф壙鐨勬柟寮� + CodeKeyAttrRepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo); + //娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗 + //鑾峰彇鎵�鏈夌殑鍏抽敭灞炴�� + Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + Map<String, String> conditionMap = new HashMap<>(); + boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); + //鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖ + boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag()); + boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag()); + boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag()); + ketAttrMap.forEach((attrId, attrVO) -> { + String value = getValueFromOrderDTO(orderDTO, attrId); + if (value == null) { + value = ""; + } + wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + }); + + //娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙� + if (!CollectionUtils.isEmpty(conditionMap)) { + conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'"); +// 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 * from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "}; + conditionMap.forEach((key, value) -> { + sql[0] += " and " + key + " = " + value; + }); + if (StringUtils.isNotBlank(orderDTO.getOid())) { + //淇敼鐨勬椂鍊欙紝闇�瑕佹帓闄よ嚜宸� + sql[0] += " and oid != '" + orderDTO.getOid() + "'"; + } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { + sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; + } + sql[0] += " and lastR = '1' and lastV = '1' "; +// if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) { + dataList=commonsMapper.selectBySql(sql[0]); + if (!CollectionUtils.isEmpty(dataList)) { +// String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}"; +// String[] objs = new String[]{trim ? "鏄�" : "鍚�", ignoreCase ? "鏄�" : "鍚�", ignoreWidth ? "鏄�" : "鍚�", trimAll ? "鏄�" : "鍚�"}; +// throw new VciBaseException("鏍规嵁鎮ㄥ~鍐欑殑鍏抽敭灞炴�х殑鍐呭锛岀粨鍚堝叧閿睘鎬ф煡璇㈣鍒欙紝鍙戠幇杩欎釜鏁版嵁宸茬粡鍦ㄧ郴缁熶腑瀛樺湪浜嗐�傝淇!銆�" + ruleInfoMsg, objs); + return dataList; + } + } + return dataList; + } /** * 灏佽鍏抽敭灞炴�х殑鏌ヨ璇彞 @@ -702,7 +766,7 @@ boolean ignoreSpace = trim || trimAll; if (StringUtils.isBlank(value)) { //涓虹┖鐨勬椂鍊欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜� - conditionMap.put("t." + attrId, "null"); + conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); } else { if (keyRuleVO != null) { String queryKey = ""; @@ -738,8 +802,12 @@ queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); conditionMap.put(queryKey, queryValue); } else { - //涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅 - conditionMap.put("t." + attrId, "'" +value+ "'"); + if(StringUtils.isNotBlank(value)) { + //涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅 + conditionMap.put("t." + attrId, "'" + value + "'"); + }else{ + conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); + } } } } -- Gitblit v1.9.3