F2-3:运行时动词闭包子指令机制 + staging 晋级(FULL_AUTO 507/HARD 74)

ScriptFacade:addFieldButton 扩第3参闭包(onClick 子指令数组)+ showConfirm
新动词,服务端急切求值闭包,子指令收进子缓冲,输出嵌套指令 JSON。
前端 scriptCommands.ts/registerReplayAction.ts:处理 addButton onClick/
confirmDialog onOk 嵌套重放,onClickActions/onOkActions 透传给 amis。
ScriptFacadeTest 补 7 个正反例(24/24 全绿)。
staging 晋级:FULL_AUTO 507(+10)/HARD 74(-12)/自动化率 82.7%,
双库各更新 801 条,e2e 30/30 全绿。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 22:24:08 +08:00
parent bc23909feb
commit 43fdfd1830
190 changed files with 2625 additions and 2454 deletions

View File

@@ -0,0 +1,163 @@
// === EIP4 P4 脚本迁移产出 ===
// template_id : 86c05eb5-753d-46e5-b958-cdbcefe7eabc
// template_name: 销项税发票
// seq : 6
// label : PARTIAL
// 余留模式 : 数据源 addItem(非标准选项 idiom); 残留字段句柄链(未覆盖动词)
// 处置 : 大部分已自动改写,余留行人工补全(见作业单)
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"}
return result;
}
//将自定义的按钮添加至
addFieldButton("INVOICELIST", "识别", {
Object fplists = getFieldValue("SELECT");
def documentfp = [];
for (int i = 0; i < fplists.size(); i++) {
def item = fplists.get(i);
if(item.get("DOCUMENT")!=null){
documentfp.addAll(item.get("DOCUMENT"));
}
};
// Console.debug(documentfp);
if (documentfp == null || documentfp.size()==0){
showToast("请先上传发票信息!", Type.ERROR_MESSAGE);
return;
};
if(documentfp && documentfp.size()>0){
def message = " ";//提示消息
documentfp.eachWithIndex{it,index->
//批量选择发票类型后给子表赋值
if(it && it.get("TEMPFILE")){
// 表示本地路径
def filePath = it.get("TEMPFILE");
//String endpointUrl = "http://192.168.20.63:5020/detection";//内网环境
String endpointUrl = "http://58.211.166.190:5020/detection";//正式环境
//文件流 上传方法
def responseBody = HTTPClientUtils.getTempFiletoFile(endpointUrl,filePath);
// Console.debug(responseBody);
if(responseBody == null || !responseBody.contains("data")){
message += "第"+(index+GetValueFunction.toDecimal(1))+"张发票接口请求超时,请检查该发票或联系管理员!\n"
}else{
def json = HTTPClientUtils.stringToJson(responseBody);
if(json && json.getString("message") && json.get("message")=="ok"){
def rows = json.get("data");
def item = rows?.get("data");
if(rows && item){
//Console.debug(item);
def fplist = [:];
fplist.put("DOCUMENT",[it]);//附件图片
//发票类型
if(rows?.get("invoiceType")!=null && rows?.get("invoiceType")!="null" && rows?.get("invoiceType")!="无"){
fplist.put("RECEIPTTYPE",rows.get("invoiceType").contains("专用") ? 3 : rows.get("invoiceType").contains("普通") ? 2 : 1);
}else{
fplist.put("RECEIPTTYPE",null);
};
if(item?.get("buyer_name")!=null && item?.getString("buyer_name")!="null" && item?.getString("buyer_name")!="无"){
fplist.put("PURCHASER",item.get("buyer_name"));
}else{
fplist.put("PURCHASER",null);
};
if(item?.get("seller_name")!=null && item?.getString("seller_name")!="null" && item?.getString("seller_name")!="无"){
fplist.put("SALESPARTY",item.get("seller_name"));
}else{
fplist.put("SALESPARTY",null);
};
if(item?.get("invoice_code")!=null && item?.getString("invoice_code")!="null" && item?.getString("invoice_code")!="无"){
fplist.put("INVOICECODE",item.get("invoice_code"));
}else{
fplist.put("INVOICECODE",null);
};
if(item?.get("invoice_number")!=null && item?.getString("invoice_number")!="null" && item?.getString("invoice_number")!="无"){
fplist.put("INVOICENO",item.get("invoice_number"));
}else{
fplist.put("INVOICENO",null);
};
if(item?.get("money")!=null && item?.getString("money")!="null" && item?.getString("money")!="无"){
fplist.put("INVOICEMONEY",transformnum(item.getString("money")));
}else{
fplist.put("INVOICEMONEY",null);
};
if(item?.get("tax")!=null && item?.getString("tax")!="null" && item?.getString("tax")!="无"){
fplist.put("TAX",transformnum(item.getString("tax")));
}else{
fplist.put("TAX",null);
};
if(item?.get("price")!=null && item?.getString("price")!="null" && item?.getString("price")!="无"){
fplist.put("TOTALMONEY",transformnum(item.getString("price")));
}else{
fplist.put("TOTALMONEY",null);
};
if(item?.get("invoice_date")!=null && item?.getString("invoice_date")!="null" && item?.getString("invoice_date")!="无"){
def date = item.getString("invoice_date");
fplist.put("INVOICEDATE",GetValueFunction.toDate(date,"yyyy年MM月dd日"));
}else{
fplist.put("INVOICEDATE",null);
};
if(item?.get("tax_rate")!=null && item?.getString("tax_rate")!="null" && item?.getString("tax_rate")!="无"){
fplist.put("TAXRATE",transformnum(item.getString("tax_rate")));
}else{
fplist.put("TAXRATE",null);
};
if(item?.get("electronic_number")!=null && item?.getString("electronic_number")!="null" && item?.getString("electronic_number")!="无"){
def electronic_number = item.getString("electronic_number");
fplist.put("GLFPHM",electronic_number);
}else{
fplist.put("GLFPHM",null);
};
if(item?.get("buyer_code")!=null && item?.getString("buyer_code")!="null" && item?.getString("buyer_code")!="无"){
def buyer_code = item.getString("buyer_code");
fplist.put("KHSH",buyer_code);
}else{
fplist.put("KHSH",null);
};
if(item?.get("seller_code")!=null && item?.getString("seller_code")!="null" && item?.getString("seller_code")!="无"){
def seller_code = item.getString("seller_code");
fplist.put("XFSH",seller_code);
}else{
fplist.put("XFSH",null);
};
if(fplist!=null){
def flag = true;
if(getFieldValue("INVOICELIST") && getFieldValue("INVOICELIST").size()>0){
for (int j = 0; j < getFieldValue("INVOICELIST").size(); j++) {
def tempitem = getFieldValue("INVOICELIST").get(j);
if((fplist.get("INVOICENO")==null || (fplist.get("INVOICENO")!=null && tempitem.get("INVOICENO") == fplist.get("INVOICENO"))) && (fplist.get("INVOICECODE")==null || (fplist.get("INVOICECODE")!=null && tempitem.get("INVOICECODE") == fplist.get("INVOICECODE")))){
flag = false;;
}
};
};
if(flag){
group.getField("INVOICELIST").addItem(fplist);
};
}
}
}else{
if(json && json.getString("message")){
message += "第"+(index+GetValueFunction.toDecimal(1))+"张发票"+json.getString("message")+"!\n";
} else{
message += "第"+(index+GetValueFunction.toDecimal(1))+"张发票接口请求超时,请检查该发票或联系管理员!\n";
}
}
}
}
}
if(message.trim()!=""){
showToast(message, Type.ERROR_MESSAGE);
}
}
}, 0)