| | |
| | | } |
| | | 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())) { |
| | | //修改的时候,需要排除自己 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验关键属性 |
| | | * |
| | | * @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; |
| | | } |
| | | |
| | | /** |
| | | * 封装关键属性的查询语句 |
| | |
| | | boolean ignoreSpace = trim || trimAll; |
| | | if (StringUtils.isBlank(value)) { |
| | | //为空的时候,不能用QueryOperation.ISNULL,平台不知道啥时候不处理这种了 |
| | | conditionMap.put("t." + attrId, "null"); |
| | | conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); |
| | | } else { |
| | | if (keyRuleVO != null) { |
| | | String queryKey = ""; |
| | |
| | | queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'"); |
| | | conditionMap.put(queryKey, queryValue); |
| | | } else { |
| | | //为空的时候不代表不校验,只是不去除相关的信息 |
| | | conditionMap.put("t." + attrId, "'" +value+ "'"); |
| | | if(StringUtils.isNotBlank(value)) { |
| | | //为空的时候不代表不校验,只是不去除相关的信息 |
| | | conditionMap.put("t." + attrId, "'" + value + "'"); |
| | | }else{ |
| | | conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL); |
| | | } |
| | | } |
| | | } |
| | | } |