|
|
@@ -7,7 +7,6 @@ import com.zsjz.ai.common.model.plat.entity.TableField;
|
|
|
import com.zsjz.ai.module.aiclean.entity.AiCleanField;
|
|
|
import com.zsjz.ai.module.aiclean.model.RuleBind;
|
|
|
import com.zsjz.ai.module.aiclean.model.TemplateCandidate;
|
|
|
-import com.zsjz.ai.module.aiclean.support.AiColumnNames;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
@@ -80,6 +79,11 @@ public final class AiRulePlan {
|
|
|
* <p><b>动态表要能还原整张 sheet</b>:AI 通常只绑上部分列(如车辆表只认出号牌/号牌种类/所有人),
|
|
|
* 其余列按原表头顺序、原值保留为 TEXT。否则 {@code ai_clean_field} 与治理树只会显示模型
|
|
|
* 命中的那几个字段,表就像被截断了一样(2026-10-18 需求)。
|
|
|
+ *
|
|
|
+ * <p><b>列名口径(2026-10-18 二次需求)</b>:物理列名固定用 {@code c0/c1/…},
|
|
|
+ * 且 {@code field_name_en} 与 {@code column_name} 完全一致 ——
|
|
|
+ * {@code ai_clean_field.column_name / field_name_en} 的列宽都只有 {@code varchar(5)}。
|
|
|
+ * AI 的语义英文名只留在 job 草稿/规则提示里,不再写进字段元数据。
|
|
|
*/
|
|
|
public static Plan forAi(List<RuleBind> binds, List<String> headerNames) {
|
|
|
Map<Integer, RuleBind> bindByIndex = new LinkedHashMap<>();
|
|
|
@@ -104,22 +108,21 @@ public final class AiRulePlan {
|
|
|
names.add(colName(headerNames, idx));
|
|
|
}
|
|
|
}
|
|
|
- List<String> safe = AiColumnNames.sanitizeAll(names);
|
|
|
List<CompiledColumn> columns = new ArrayList<>();
|
|
|
List<AiCleanField> fields = new ArrayList<>();
|
|
|
for (int pos = 0; pos < indexes.size(); pos++) {
|
|
|
int fileColIndex = indexes.get(pos);
|
|
|
RuleBind bind = bindByIndex.get(fileColIndex);
|
|
|
String nameCn = names.get(pos);
|
|
|
- String fieldNameEn = bind == null || StrUtil.isBlank(bind.getFieldNameEn())
|
|
|
- ? nameCn
|
|
|
- : bind.getFieldNameEn();
|
|
|
+ // 列名固定 c{位置}:既保证长度 ≤5(ai_clean_field 两列都是 varchar(5)),
|
|
|
+ // 也保证 field_name_en 与 column_name 完全一致
|
|
|
+ String columnName = "c" + pos;
|
|
|
String type = bind == null ? "TEXT" : typeOf(bind);
|
|
|
boolean required = bind != null && Boolean.TRUE.equals(bind.getRequired());
|
|
|
AiCleanField f = new AiCleanField();
|
|
|
- f.setColumnName(safe.get(pos));
|
|
|
+ f.setColumnName(columnName);
|
|
|
f.setFieldNameCn(nameCn);
|
|
|
- f.setFieldNameEn(fieldNameEn);
|
|
|
+ f.setFieldNameEn(columnName);
|
|
|
f.setFieldType(type);
|
|
|
f.setRequired(required ? 1 : 0);
|
|
|
f.setFieldLen(0);
|
|
|
@@ -127,7 +130,7 @@ public final class AiRulePlan {
|
|
|
f.setColIndex(fileColIndex);
|
|
|
f.setMatched(1);
|
|
|
fields.add(f);
|
|
|
- columns.add(CompiledColumn.of(fileColIndex, safe.get(pos), fieldNameEn, type, required, 0,
|
|
|
+ columns.add(CompiledColumn.of(fileColIndex, columnName, columnName, type, required, 0,
|
|
|
bind == null ? List.of() : AiRuleCompiler.compileFuns(bind)));
|
|
|
}
|
|
|
return new Plan(columns, fields);
|