- 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>
161 lines
9.8 KiB
Groovy
161 lines
9.8 KiB
Groovy
// === 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;
|
||
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)
|
||
|