Files
eip4-platform/tools/s3_rewriter/output/rewritten/86c05eb5-753d-46e5-b958-cdbcefe7eabc/6.HARD.groovy
zhengwr a711ecd8f0 F2-4(一): 修 XML 实体污染并重批重入库,固化标准入库器
- run_eval: PG xpath(...)::text 保留实体转义(< → &lt;),抽取后补 XML 预定义实体反转义
  (等价手册 §5.3 dom4j getText() 语义);293 个污染产物清零,Groovy 编译失败根因消除
- 缓存重建(源=eip4dev,1428 条:1 模板改名+1 新增脚本属数据演进);全量重跑
  497/30/86/815,自动化率 81.1% 守住 ≥80%
- 重大发现:同模板内脚本顺序在两次抽取间会交换((templateId,seq) 非稳定键,
  welfare 模板 seq1↔seq2 实锤)——重批后 onEvent seq 已与磁盘对齐,长期需内容哈希键(登记 F2-4)
- tools/page-schema-loader/load_page_schema.py:幂等标准入库器(etag=sha256,version 递增,
  仅允许 localhost 双库);本次双库各更新 756/幂等跳过 733,e2e 28/28 保持全绿
- 坑:mvn exec:java 的 -Dexec.args 引号空参会被吞导致参数错位(密码用占位符代替空串)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 21:27:38 +08:00

172 lines
10 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// === EIP4 P4 脚本迁移产出 ===
// template_id : 86c05eb5-753d-46e5-b958-cdbcefe7eabc
// template_name: 销项税发票
// seq : 6
// 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);