任务1 全量改写执行: - run_rewrite.py 对客户库缓存 1,427 条逐条改写,按 template_id+脚本序号落盘 output/rewritten/(497 FULL_AUTO + 30 PARTIAL + 85 HARD + 815 NO_S3) - 人工作业单 115 份(PARTIAL 30 + HARD 85),每份附原文/已改部分/余留模式/建议改法/工时口径 - 自动化率 81.2% 复现 C4 实测,0 误改 任务2 facade 动词表运行时: - ScriptFacade 把 31 改写目标动词 + bindField 作为 Groovy 闭包注入 Bindings (PoC enableButton 模式扩展);服务端语义动词直接求值,UI 语义动词捕获为 amis 事件动作指令 JSON(actionType/componentId/args) - 保真层纪律:全在 com.eip4 现代层,com.dsasp 源码零改,ArchUnit 复跑通过 - ScriptExecuteController 提供 /api/script/execute 与 /api/script/execute-template 验证: - 单测 17 方法逐动词覆盖,均经真实 Groovy 过保真层引擎,BUILD SUCCESS - 集成 6 条真实 FULL_AUTO 改写脚本经 8086 执行,amis 指令协议合规 - 回归 PoC script-test 通过,ArchUnit 架构纪律通过 报告 tools/s3_rewriter/P4脚本迁移执行报告.md;新坑入 docs/迁移手册.md 5.39/9.3 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
172 lines
10 KiB
Groovy
172 lines
10 KiB
Groovy
// === EIP4 P4 脚本迁移产出 ===
|
||
// template_id : 86c05eb5-753d-46e5-b958-cdbcefe7eabc
|
||
// template_name: 销项税发票
|
||
// seq : 3
|
||
// label : HARD
|
||
// 硬 S3 原因 : 动态创建 Vaadin 组件
|
||
// 处置 : 原文保留,进人工排期(amis dialog/service 重写)
|
||
import com.dsasp.server.common.exception.ValidationException;
|
||
import com.dsasp.server.common.util.HTTPClientUtils;
|
||
import com.vaadin.ui.Button;
|
||
import com.vaadin.ui.Button.ClickEvent;
|
||
import com.vaadin.ui.Button.ClickListener;
|
||
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;
|
||
}
|
||
|
||
|
||
def invoicelist = group.getField("INVOICELIST");
|
||
def document = group.getField("SELECT");
|
||
|
||
final Button cb = new Button("识别");
|
||
cb?.addClickListener(new ClickListener() {
|
||
public void buttonClick(ClickEvent event) {
|
||
Object fplists = document?.getValue();
|
||
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){
|
||
Notification.show("请先上传发票信息!", 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(invoicelist.getValue() && invoicelist.getValue().size()>0){
|
||
for (int j = 0; j < invoicelist.getValue().size(); j++) {
|
||
def tempitem = invoicelist.getValue().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){
|
||
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()!=""){
|
||
Notification.show(message, Type.ERROR_MESSAGE);
|
||
}
|
||
}
|
||
};
|
||
});
|
||
|
||
//将自定义的按钮添加至
|
||
invoicelist?.addButton(cb, 0);
|
||
|