| | |
| | | import com.vci.ubcs.code.mapper.CodeWupinMapper; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.util.ClientBusinessObject; |
| | | import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.UITablePageVO; |
| | |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.constant.RegExpConstant; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | |
| | | 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; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.Cache; |
| | |
| | | } |
| | | return comboboxKVs; |
| | | } |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * |
| | |
| | | }); |
| | | |
| | | andCondtionMap.forEach((k, v) -> { |
| | | andSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, attrVOMap)); |
| | | andSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, attrVOMap,btmType)); |
| | | }); |
| | | orConditionMap.forEach((k, v) -> { |
| | | orSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, attrVOMap)); |
| | | orSql.add(getConditionSql(k.toLowerCase(), v, referFieldMap, attrVOMap,btmType)); |
| | | }); |
| | | } |
| | | //组合起来 |
| | |
| | | * @param attrVOMap 属性的映射 |
| | | * @return Sql语句 |
| | | */ |
| | | private String getConditionSql(String key, String value, Map<String/**参照的属性**/, String/**实际的属性**/> referFieldMap, Map<String, CodeClassifyTemplateAttrVO> attrVOMap) { |
| | | private String getConditionSql(String key, String value, Map<String/**参照的属性**/, String/**实际的属性**/> referFieldMap, Map<String, CodeClassifyTemplateAttrVO> attrVOMap,String btmType) { |
| | | /*if (!Func.hasEmpty(new Object[]{key,value}) && !key.endsWith("_ignore")) { |
| | | if (key.endsWith("_like")) { |
| | | String field = UBCSSqlKeyword.getColumn(key, "_like"); |
| | | if (referFieldMap.containsKey(field)) { |
| | | //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧 |
| | | return referFieldMap.get(field) + SPACE + "LIKE" + SPACE + "concat(%,"+"concat('" + value + "'" + SPACE+",%)"; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + " <= " + getStringValueInWhere(field, value, attrVOMap); |
| | | } |
| | | } else if (key.endsWith("_notequal")) { |
| | | qw.ne(UBCSSqlKeyword.getColumn(key, "_notequal"), v); |
| | | } else if (key.endsWith("_likeleft")) { |
| | | qw.likeLeft(UBCSSqlKeyword.getColumn(key, "_likeleft"), v); |
| | | } else if (key.endsWith("_likeright")) { |
| | | qw.likeRight(UBCSSqlKeyword.getColumn(key, "_likeright"), v); |
| | | } else if (key.endsWith("_notlike")) { |
| | | qw.notLike(UBCSSqlKeyword.getColumn(key, "_notlike"), v); |
| | | } else if (key.endsWith("_ge")) { |
| | | String field = UBCSSqlKeyword.getColumn(key, "_ge"); |
| | | if (referFieldMap.containsKey(field)) { |
| | | //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧 |
| | | return referFieldMap.get(field) + SPACE + " >= '" + value + "'" + SPACE; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + " >= " + getStringValueInWhere(value, field, attrVOMap); |
| | | } |
| | | } else if (key.endsWith("_le")) { |
| | | //说明是<=的。我们需要先获取一下 |
| | | String field = UBCSSqlKeyword.getColumn(key, "_le"); |
| | | if (referFieldMap.containsKey(field)) { |
| | | //说明还是参照里面的,我们默认这种情况下都是字符串吧,因为参照的属性不一定用的平台的属性池里的,所以大部分情况下,显示的属性都是字符串吧 |
| | | return referFieldMap.get(field) + SPACE + " <= '" + value + "'" + SPACE; |
| | | } else { |
| | | return (field.contains(".") ? "" : "t.") + field + SPACE + " <= " + getStringValueInWhere(field, value, attrVOMap); |
| | | } |
| | | } else if (key.endsWith("_gt")) { |
| | | qw.gt(UBCSSqlKeyword.getColumn(key, "_gt"), v); |
| | | } else if (key.endsWith("_lt")) { |
| | | qw.lt(UBCSSqlKeyword.getColumn(key, "_lt"), v); |
| | | } else if (key.endsWith("_datege")) { |
| | | qw.ge(UBCSSqlKeyword.getColumn(key, "_datege"), DateUtil.parse(String.valueOf(v), "yyyy-MM-dd HH:mm:ss")); |
| | | } else if (key.endsWith("_dategt")) { |
| | | qw.gt(UBCSSqlKeyword.getColumn(key, "_dategt"), DateUtil.parse(String.valueOf(v), "yyyy-MM-dd HH:mm:ss")); |
| | | } else if (key.endsWith("_dateequal")) { |
| | | qw.eq(UBCSSqlKeyword.getColumn(key, "_dateequal"), DateUtil.parse(String.valueOf(v), "yyyy-MM-dd HH:mm:ss")); |
| | | } else if (key.endsWith("_datele")) { |
| | | qw.le(UBCSSqlKeyword.getColumn(key, "_datele"), DateUtil.parse(String.valueOf(v), "yyyy-MM-dd HH:mm:ss")); |
| | | } else if (key.endsWith("_datelt")) { |
| | | qw.lt(UBCSSqlKeyword.getColumn(key, "_datelt"), DateUtil.parse(String.valueOf(v), "yyyy-MM-dd HH:mm:ss")); |
| | | } else if (key.endsWith("_null")) { |
| | | qw.isNull(UBCSSqlKeyword.getColumn(key, "_null")); |
| | | } else if (key.endsWith("_notnull")) { |
| | | qw.isNotNull(UBCSSqlKeyword.getColumn(key, "_notnull")); |
| | | } else { |
| | | qw.eq(UBCSSqlKeyword.getColumn(key, "_equal"), v); |
| | | } |
| | | |
| | | }*/ |
| | | |
| | | if (key.endsWith("_begin")) { |
| | | //说明是>=的。我们需要先获取一下 |
| | | String field = (key.substring(0, key.length() - 6).toLowerCase().trim()); |
| | |
| | | if (referFieldMap.containsKey(key)) { |
| | | //说明是参照的,我们参照的查询都认为是字符串,如果是时间格式的查询肯定有问题, |
| | | String selectKey = referFieldMap.get(key); |
| | | return getSqlByValue(selectKey, value, null); |
| | | return getSqlByValue(selectKey, value, null,btmType); |
| | | } else { |
| | | return getSqlByValue(key, value, attrVOMap); |
| | | return getSqlByValue(key, value, attrVOMap,btmType); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查看是否默认属性 |
| | | * @param selectKey |
| | | * @param btmType |
| | | * @return |
| | | */ |
| | | private boolean isDefaultAttr(String selectKey, String btmType){ |
| | | if(StringUtils.isBlank(btmType)){ |
| | | return false; |
| | | } |
| | | R<BtmTypeVO> r = btmTypeClient.getDefaultAttrByBtmId(btmType); |
| | | List<BtmTypeAttributeVO> attributes = r.getData().getAttributes(); |
| | | if(r.getCode() != 200 || attributes.isEmpty()){ |
| | | return false; |
| | | } |
| | | return attributes.stream().anyMatch(item->item.getId().equals(selectKey)); |
| | | } |
| | | |
| | | /** |
| | | * 封装最终的sql语句中的值部分 |
| | | * |
| | | * @param selectKey 查询的字段 |
| | |
| | | * @param attrVOMap 属性的显示对象映射 |
| | | * @return sql里的值 |
| | | */ |
| | | private String getSqlByValue(String selectKey, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap) { |
| | | private String getSqlByValue(String selectKey, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap,String btmType) { |
| | | StringBuilder sql = new StringBuilder(); |
| | | // TODO 待完善 |
| | | // if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || attributeService.isDefaultAttr(selectKey) || selectKey.matches(RegExpConstant.LETTER))) { |
| | | // sql.append("t."); |
| | | // } |
| | | // TODO 已完善 |
| | | if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || isDefaultAttr(selectKey,btmType) || selectKey.matches(RegExpConstant.LETTER))) { |
| | | sql.append("t."); |
| | | } |
| | | if (value.startsWith(QueryOptionConstant.IN)) { |
| | | sql.append(selectKey) |
| | | .append(SPACE) |