F2-4b: rewrite 规则扩展 + item 改进 + 最终批量结果

- rewrite.py: 新增 _VAADIN_EXTRA_IMPORT_RE / _DSASP_CLIENT_IMPORT_RE /
  _ENVIROMENT_GET_IMPORT_RE 三条 import 剥离规则,统一在 5.9 清理节
  运行;补多余引号修复(源数据 bug "...SQL 100"";")
- run_batch_regression.py: connect_db 优先连本地 eip4dev:5433,
  回退远程 192.168.20.68:5435
- output/rewritten/*.groovy: 规则重跑后的 rewritten 产物更新
- output/manual_workpackage/*.md: 对应工包重生成
- output/batch_regression_20260612_053253.json: 最终批跑结果
  FULL_AUTO 94.1%(476/506);删除 3 个中间产物 JSON
- docs/P1/F2-4批量回归报告.md: 最终通过率写入报告

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 05:33:41 +08:00
parent 0e3f204ec8
commit aa576ea2c6
48 changed files with 17606 additions and 232 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -57,8 +57,6 @@ lists.addButton(field, 0);
## 2. 已改写部分(自动产出)
```groovy
import com.dsasp.viewframework.MultiSelectField;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
final def group1 = group;
if (lists == null) {

View File

@@ -78,12 +78,6 @@ professionals?.showDeleteButton(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
import com.dsasp.client.viewframework.listener.ConfirmDialogListener;
import com.vaadin.ui.Link;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Label;

View File

@@ -57,8 +57,6 @@ lists.addButton(field, 0);
## 2. 已改写部分(自动产出)
```groovy
import com.dsasp.viewframework.MultiSelectField;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
final def group1 = group;
if (lists == null) {

View File

@@ -22,7 +22,6 @@ tie.addExportButton(4);
addSubTableButton("MATERIALDETAILS", "SELECT", 0);
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materiallist,"com.dsasp.pm.materialmanagertj.client.MaterialRequestMasterPlanDetailImportOfTJ");
group.getField("MATERIALDETAILS").setData(tie);
tie.addImportButton(3);

View File

@@ -78,12 +78,6 @@ professionals?.showDeleteButton(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
import com.dsasp.client.viewframework.listener.ConfirmDialogListener;
import com.vaadin.ui.Link;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Label;

View File

@@ -176,9 +176,6 @@ invoicelist?.addButton(cb, 0);
```groovy
import com.dsasp.server.common.exception.ValidationException;
import com.dsasp.server.common.util.HTTPClientUtils;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
def transformnum (moneyStr) {
def numericStr = moneyStr.replaceAll(/[^\d.]/, '') // 移除非数字字符:ml-citation{ref="5,11" data="citationList"}
def result = numericStr.isNumber() ? numericStr.toBigDecimal() : null // 高精度转换:ml-citation{ref="9,11" data="citationList"}

View File

@@ -68,9 +68,6 @@ group.getField("ISPREPARATION")?.setVisible(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("MATERIALDETAILS")?.table;
table?.setImmediate(true);//设置验证
@@ -107,7 +104,6 @@ Object o = table?.getValue();
table.select(o);
}, 1)
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materialList,"com.dsasp.pm.materialmanagertj.client.MaterialApplyDetailImportOfTJ");
tie.addImportButton(4);
tie.addExportButton(5);

View File

@@ -44,9 +44,6 @@ user?.deleteButton.setVisible(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("PM_PROJECT_USERS")?.table;

View File

@@ -168,7 +168,6 @@ assetssortId?.setReadOnly(true);
## 2. 已改写部分(自动产出)
```groovy
import com.dsasp.server.common.dataDic.service.POJOCRUDService;
import com.vaadin.ui.PopupDateField;
def value = event.getProperty().getValue();

View File

@@ -177,9 +177,6 @@ invoicelist?.addButton(cb, 0);
```groovy
import com.dsasp.server.common.exception.ValidationException;
import com.dsasp.server.common.util.HTTPClientUtils;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
def transformnum (moneyStr) {
def numericStr = moneyStr.replaceAll(/[^\d.]/, '') // 移除非数字字符:ml-citation{ref="5,11" data="citationList"}
def result = numericStr.isNumber() ? numericStr.toBigDecimal() : null // 高精度转换:ml-citation{ref="9,11" data="citationList"}

View File

@@ -18,7 +18,6 @@ tie.addExportButton(4);
## 2. 已改写部分(自动产出)
```groovy
import com.dsasp.client.viewframework.util.TableImportExport;
//添加按钮
addSubTableButton("RECORDDETAILS", "SELECT", 0);
//导入按钮

View File

@@ -68,9 +68,6 @@ group.getField("ISPREPARATION")?.setVisible(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("MATERIALDETAILS")?.table;
table?.setImmediate(true);//设置验证
@@ -107,7 +104,6 @@ Object o = table?.getValue();
table.select(o);
}, 1)
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materialList,"com.dsasp.pm.materialmanagertj.client.MaterialApplyDetailImportOfTJ");
tie.addImportButton(4);
tie.addExportButton(5);

View File

@@ -44,9 +44,6 @@ user?.deleteButton.setVisible(false);
## 2. 已改写部分(自动产出)
```groovy
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("PM_PROJECT_USERS")?.table;

View File

@@ -6,8 +6,6 @@
// 余留模式 : 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.viewframework.MultiSelectField;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
final def group1 = group;
if (lists == null) {

View File

@@ -6,12 +6,6 @@
// 余留模式 : raw .table 组件访问; 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
import com.dsasp.client.viewframework.listener.ConfirmDialogListener;
import com.vaadin.ui.Link;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Label;

View File

@@ -5,7 +5,6 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.dsasp.server.common.dataDic.service.POJOCRUDService;
import com.vaadin.ui.PopupDateField;
def value = event.getProperty().getValue();

View File

@@ -5,9 +5,6 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
//将自定义的按钮添加至
addSubTableButton("USERIDS", "SELECT", 0);

View File

@@ -6,8 +6,6 @@
// 余留模式 : 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.viewframework.MultiSelectField;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
final def group1 = group;
if (lists == null) {

View File

@@ -4,8 +4,6 @@
// seq : 1
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
//def tList = [];
//
//def results = GetServicesFunction.listSelectResult([:],"HR_WELFARECATEGORY");

View File

@@ -4,9 +4,6 @@
// seq : 1
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
//将自定义的按钮添加至
addSubTableButton("HR_EMPLOYEES", "SELECT", 0);

View File

@@ -5,9 +5,6 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
//将自定义的按钮添加至
addSubTableButton("USERIDS", "SELECT", 0);

View File

@@ -4,8 +4,5 @@
// seq : 3
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
addSubTableButton("SAFETYRECTIFICATIONTERMS", "SELECT", 0);

View File

@@ -8,7 +8,6 @@
addSubTableButton("MATERIALDETAILS", "SELECT", 0);
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materiallist,"com.dsasp.pm.materialmanagertj.client.MaterialRequestMasterPlanDetailImportOfTJ");
group.getField("MATERIALDETAILS").setData(tie);
tie.addImportButton(3);

View File

@@ -5,6 +5,8 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
//将自定义的按钮添加至
addSubTableButton("SIGNDETAILS", "SELECT", 0);
addFieldButton("SIGNDETAILS", "全选签到", {

View File

@@ -6,12 +6,6 @@
// 余留模式 : raw .table 组件访问; 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
import com.dsasp.client.viewframework.listener.ConfirmDialogListener;
import com.vaadin.ui.Link;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Label;

View File

@@ -4,7 +4,4 @@
// seq : 2
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
addSubTableButton("UNITS", "SELECT", 0);

View File

@@ -5,14 +5,10 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
/*
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
*/
def inventorydetailslist = getFieldValue("INVENTORYDETAILS");//盘点明细值
//导入功能
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(inventorydetails,"com.dsasp.hr.checkattendancemanager.client.CheckinoutImport"){
public void importData(List<Map<String,Object>> datas){
def map = [:];

View File

@@ -7,9 +7,6 @@
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.server.common.exception.ValidationException;
import com.dsasp.server.common.util.HTTPClientUtils;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
def transformnum (moneyStr) {
def numericStr = moneyStr.replaceAll(/[^\d.]/, '') // 移除非数字字符:ml-citation{ref="5,11" data="citationList"}
def result = numericStr.isNumber() ? numericStr.toBigDecimal() : null // 高精度转换:ml-citation{ref="9,11" data="citationList"}

View File

@@ -5,9 +5,6 @@
// label : PARTIAL
// 余留模式 : raw .table 组件访问; 数据源 addItem(非标准选项 idiom); 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("MATERIALDETAILS")?.table;
table?.setImmediate(true);//设置验证
@@ -44,7 +41,6 @@ Object o = table?.getValue();
table.select(o);
}, 1)
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materialList,"com.dsasp.pm.materialmanagertj.client.MaterialApplyDetailImportOfTJ");
tie.addImportButton(4);
tie.addExportButton(5);

View File

@@ -4,8 +4,6 @@
// seq : 1
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
//def tList = [];
//def results = GetServicesFunction.listSelectResult([:],"HR_WELFARECATEGORY");
//

View File

@@ -5,14 +5,10 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
/*
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
*/
def inventorydetailslist = getFieldValue("INVENTORYDETAILS");//盘点明细值
//导入功能
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(inventorydetails,"com.dsasp.pm.turnovermaterialmanager.client.TurnOverMaterialInventoryDetailsImport"){
public void importData(List<Map<String,Object>> datas){

View File

@@ -5,9 +5,6 @@
// label : PARTIAL
// 余留模式 : raw .table 组件访问; 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("PM_PROJECT_USERS")?.table;

View File

@@ -6,7 +6,7 @@
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.dsasp.server.common.dataDic.bean.CustomSearchConditional;
def strSql = " P.PROJECTSTAGE>=8 AND P.PROJECTSTAGE <= 100"";
def strSql = " P.PROJECTSTAGE>=8 AND P.PROJECTSTAGE <= 100";
def map = ["PROJECTSTAGE":new CustomSearchConditional(strSql)];
map["FILIALE"] = getFieldValue("ORGID");

View File

@@ -6,7 +6,6 @@
// 余留模式 : 属性数据源链(非 setReadOnly 收尾); 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.server.common.dataDic.service.POJOCRUDService;
import com.vaadin.ui.PopupDateField;
def value = event.getProperty().getValue();

View File

@@ -5,8 +5,6 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.dsasp.server.common.dataDic.service.POJOCRUDService;
import com.vaadin.ui.PopupDateField;
def value = event.getProperty().getValue();
////////////////////////////////////////////////////////

View File

@@ -4,8 +4,6 @@
// seq : 1
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
//def tList = [];
//def results = GetServicesFunction.listSelectResult([:],"HR_WELFARECATEGORY");
//

View File

@@ -5,6 +5,8 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
//将自定义的按钮添加至
//addSubTableButton("TASKS", "SELECT", 0);
addFieldButton("TASKS", "查询", {

View File

@@ -5,8 +5,5 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
//将自定义的按钮添加至
addSubTableButton("INVOICELIST", "SELECT", 0);

View File

@@ -7,9 +7,6 @@
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.server.common.exception.ValidationException;
import com.dsasp.server.common.util.HTTPClientUtils;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
def transformnum (moneyStr) {
def numericStr = moneyStr.replaceAll(/[^\d.]/, '') // 移除非数字字符:ml-citation{ref="5,11" data="citationList"}
def result = numericStr.isNumber() ? numericStr.toBigDecimal() : null // 高精度转换:ml-citation{ref="9,11" data="citationList"}

View File

@@ -5,7 +5,6 @@
// label : PARTIAL
// 余留模式 : 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.dsasp.client.viewframework.util.TableImportExport;
//添加按钮
addSubTableButton("RECORDDETAILS", "SELECT", 0);
//导入按钮

View File

@@ -4,9 +4,6 @@
// seq : 1
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
//将自定义的按钮添加至
addSubTableButton("DETAILS", "SELECT", 0);

View File

@@ -5,9 +5,6 @@
// label : PARTIAL
// 余留模式 : raw .table 组件访问; 数据源 addItem(非标准选项 idiom); 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("MATERIALDETAILS")?.table;
table?.setImmediate(true);//设置验证
@@ -44,7 +41,6 @@ Object o = table?.getValue();
table.select(o);
}, 1)
import com.dsasp.client.viewframework.util.TableImportExport;
def tie = new TableImportExport(materialList,"com.dsasp.pm.materialmanagertj.client.MaterialApplyDetailImportOfTJ");
tie.addImportButton(4);
tie.addExportButton(5);

View File

@@ -5,6 +5,8 @@
// label : FULL_AUTO
// 处置 : 全自动改写完成,直接入 P4 转换流水线
//将自定义的按钮添加至
//addSubTableButton("TASKS", "SELECT", 0);
addFieldButton("TASKS", "查询", {

View File

@@ -5,9 +5,6 @@
// label : PARTIAL
// 余留模式 : raw .table 组件访问; 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
final Object table = group.getField("PM_PROJECT_USERS")?.table;

View File

@@ -447,6 +447,24 @@ _NOTIF_IMPORT_RE = re.compile(
re.MULTILINE,
)
# F2-4b 修复: 扩展 import 剥离规则
# 以下类在 EIP4 classpath 不存在,必须剥除否则 Groovy 编译失败
# 规则:Vaadin 客户端类 + com.dsasp.client.* 全剥
# com.dsasp.server.common.util.EnviromentGet 不在 platform-legacy-core,剥
# com.dsasp.server.common.dataDic.* 在 platform-legacy-core 存在,不剥
_VAADIN_EXTRA_IMPORT_RE = re.compile(
r'^[ \t]*import\s+com\.vaadin\.(?:server\.VaadinService|ui\.PopupDateField);\s*\n?',
re.MULTILINE,
)
_DSASP_CLIENT_IMPORT_RE = re.compile(
r'^[ \t]*import\s+com\.dsasp\.client\.[\w\.]+;\s*\n?',
re.MULTILINE,
)
_ENVIROMENT_GET_IMPORT_RE = re.compile(
r'^[ \t]*import\s+com\.dsasp\.server\.common\.util\.EnviromentGet;\s*\n?',
re.MULTILINE,
)
# 匹配: [final] Button VAR = new Button("文案") 或 [def/final] Button VAR = new Button("文案")
_BTN_DECL_RE = re.compile(
r'^[ \t]*(?:final\s+)?(?:def\s+)?Button\s+(\w+)\s*=\s*new\s+Button\((["\'][^"\']+["\'])\)\s*;?[ \t]*(?://[^\n]*)?\n?',
@@ -979,6 +997,13 @@ def rewrite_script(source: str) -> Tuple[str, List[RewriteDetail], str]:
"""
details: List[RewriteDetail] = []
# ── 4.9 原始脚本预处理:修复已知源数据 bug ────────────────────
# F2-4b: 原始脚本中字符串字面量末尾有多余双引号(如 "...SQL 100"";),
# 这是上游数据入库时的编码问题,会导致 Groovy 编译失败。
# 规则:只修复 非空字符串内容(不跨行)后面跟了多余 """ 的模式。
# 关键约束:[^"\n]+ 排除换行,防止跨行匹配到合法的 def sql = ""; 语句。
source = re.sub(r'("[^"\n]+)""(;)', r'\1"\2', source)
# ── 5.0 规则族2: 动态按钮家族(先于 HARD 检测运行)──────────
# new Button + addClickListener + fieldVar.addButton(btnVar, N)
# → addFieldButton("FIELD", "文案", {闭包体}, N)
@@ -1110,10 +1135,21 @@ def rewrite_script(source: str) -> Tuple[str, List[RewriteDetail], str]:
count=opt_count,
))
# ── 5.9 全局 Vaadin import 清理 ──────────────────────────
# ── 5.9 全局 Vaadin/Legacy import 清理 ──────────────────────────
# F2-4: Notification_show / dynamic_button 等规则改写后,vaadin Notification
# import 已无用;在分类前统一剥离,避免引擎编译失败。
working = _NOTIF_IMPORT_RE.sub('', working)
# F2-4b: Button/ClickEvent/ClickListener import 无条件剥除——
# dynamic_button 规则只在 new Button()+addClickListener 形态下改写并剥 import,
# 但 addButton(getField(...),N) 形态不触发改写器,其 Button import 仍残留。
# Button/ClickEvent/ClickListener 在 EIP4 classpath 不存在,统一剥除无副作用。
working = _BTN_IMPORT_RE.sub('', working)
working = _LISTENER_IMPORT_RE.sub('', working)
# F2-4b: 扩展剥离——VaadinService/PopupDateField/dsasp.client.*/EnviromentGet
# 均不在 EIP4 classpath,保留会导致 Groovy MultipleCompilationErrors
working = _VAADIN_EXTRA_IMPORT_RE.sub('', working)
working = _DSASP_CLIENT_IMPORT_RE.sub('', working)
working = _ENVIROMENT_GET_IMPORT_RE.sub('', working)
# ── 5.10 分类 ──────────────────────────────────────────────
if not _has_s3(working):

View File

@@ -123,14 +123,27 @@ def try_get_db_item(tid: str, db_conn) -> dict:
def connect_db():
"""F2-4b 修复:优先连接本地 eip4dev(5433),回退远程 192.168.20.68:5435。"""
try:
import psycopg2
# 优先本地 eip4dev
try:
conn = psycopg2.connect(
host="localhost", port=5433, dbname="eip4dev",
user="eip4", password="", connect_timeout=5,
options="-c search_path=eip3",
)
print(" 数据库连接成功(本地 eip4dev:5433),将抽取真实行数据作 item")
return conn
except Exception:
pass
# 回退远程
conn = psycopg2.connect(
host="192.168.20.68", port=5435, dbname="postgres",
user="ceshi", password="ceshi", connect_timeout=5,
options="-c search_path=eip3",
)
print(" 数据库连接成功,将抽取真实行数据作 item")
print(" 数据库连接成功(远程 192.168.20.68:5435),将抽取真实行数据作 item")
return conn
except Exception as e:
print(f" 数据库不可达 ({e}),item 将使用 {{}}")