Files
eip4-platform/tools/s3_rewriter/output/rewritten/7d50dd37-9892-410e-9fdc-731f24fbfd80/1.HARD.groovy
zhengwr aefb0e2eb9 P4-2 脚本迁移线:全量改写产出 + facade 动词表运行时实现
任务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>
2026-06-11 16:10:22 +08:00

190 lines
17 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 : 7d50dd37-9892-410e-9fdc-731f24fbfd80
// template_name: 项目成本拆分
// seq : 1
// label : HARD
// 硬 S3 原因 : 动态创建 Vaadin 组件
// 处置 : 原文保留,进人工排期(amis dialog/service 重写)
import com.vaadin.ui.Button;
import com.vaadin.ui.Alignment;
import com.dsasp.client.viewframework.util.TemplateUtil;
import com.dsasp.client.viewframework.util.MainTabUtil;
import com.dsasp.client.viewframework.component.MainComponent;
def opertor = group.getField("BUTTON");
def vl = opertor?.parent;
Button button = new Button("生成收入拆分表");
vl.addComponent(button,0);
vl.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
def projectid = getFieldValue("PROJECTID");
def cid = getFieldValue("BUDGETUNITID");
if(projectid==null){
return;
}
/****专业分包***/
def returncol = [];
returncol.add("PROJECTID");
returncol.add("BUDGETUNITID");
returncol.add("WORKCONTENT");
returncol.add("SUBPACKAGE");
returncol.add("SUBPACKAGEMONEY");
def substr = " select projectid,budgetunitid,workcontent,subpackage,sum(p.listprice) as subpackagemoney";
substr=substr+" from(";
substr=substr+" select projectid,budgetunitid,cbudgetlistid,workcontent,subpackage,round(min(workload)*sum(quotaprice),2) as listprice";
substr=substr+" from(";
substr=substr+" select pm_project_id as projectid,pm_budgetunit_id as budgetunitid,projectname||budgetunitname||codedes as workcontent,p.cbudgetlistid,p.subpackage,workload,round(q.quotacontent *(rcjprice+(case when p.isincludemanagent = 1 then q.managementexpense else 0 end)+(case when p.isprofit = 1 then q.drofit else 0 end)),2) as quotaprice";
substr=substr+" from pm_cbudgetsubplan p";
substr=substr+" join lateral(select sum(engineeringquantity) as workload from pm_cbudgetlistamount l where l.cbudgetlistid = p.cbudgetlistid) workload on true";
substr=substr+" join pm_cbudgetquota q on p.cbudgetlistid=q.cbudgetlistid";
substr=substr+" left join lateral(select sum(round(rcjcontent*c.unitprice,2)) rcjprice from pm_cbudgetquotarcjcontent c join pm_cbudgetsubplan_resource r on c.projectrcjid = r.resourceid and r.planid = p.pm_cbudgetsubplan_id where c.cbudgetquotaid = q.pm_cbudgetquota_id) rcjprice on true";
substr=substr+" left join lateral(select pm_budgetunit_id,budgetunitname from pm_budgetunit where pm_project_id = q.projectid and pm_budgetunit_id = q.budgetunitid) bunitname on true";
substr=substr+" left join lateral(select pm_project_id,projectname from pm_project where pm_project_id = q.projectid) project on true";
substr=substr+" left join lateral(select codedes from sys_enumerate where codevalue = p.subpackage and sys_enumeratetype_id = 'specialtySubCategory') codedes on true";
substr=substr+" where q.projectid = '"+projectid+"' and q.budgetunitid='"+cid+"'";
substr=substr+" ) as p group by projectid,budgetunitid,p.cbudgetlistid,workcontent,p.subpackage";
substr=substr+" ) as p group by projectid,budgetunitid,workcontent,subpackage";
//计算分包
def returnlist = GetServicesFunction.listSelectResultBySql([:],"VIEW_PM_SUBPACKAGEPLAN",substr,returncol);
bindField("SUBS",returnlist);
/****劳务***/
returncol = [];
returncol.add("PROJECTID");
returncol.add("BUDGETUNITID");
returncol.add("WORKCONTENT");
returncol.add("RESOURCEID");
returncol.add("WORKLOAD");
returncol.add("UNITPRICE");
returncol.add("TOTALPRICE");
def lwstr = " select projectid,budgetunitid,projectname||budgetunitname as workcontent,resourceid,workload,totalprice,unitprice";
lwstr=lwstr+" from(";
lwstr=lwstr+" select projectid,budgetunitid,resourceid,sum(workload) as workload,sum(totalprice) as totalprice,case when sum(workload)=0 then 0 else round(sum(totalprice)/sum(workload),2) end as unitprice";
lwstr=lwstr+" from(";
lwstr=lwstr+" select p.projectid,p.budgetunitid,rl.stuffid as resourceid,round(listwork*quotacontent*rcjcontent,4) as workload,round(listwork*quotacontent*rcjcontent*r.unitprice,2) as totalprice";
lwstr=lwstr+" from pm_cbudgetlist p";
lwstr=lwstr+" join lateral(select sum(engineeringquantity) as listwork from pm_cbudgetlistamount l where l.cbudgetlistid = p.pm_cbudgetlist_id) listwork on true";
lwstr=lwstr+" join pm_cbudgetquota q on p.pm_cbudgetlist_id=q.cbudgetlistid";
lwstr=lwstr+" join pm_cbudgetquotarcjcontent r on r.cbudgetquotaid = q.pm_cbudgetquota_id";
lwstr=lwstr+" join pm_projectresource pr on pr.pm_projectresource_id = r.projectrcjid";
lwstr=lwstr+" left join pm_stuffbudgetresource rl on pr.pm_projectresource_id = rl.resourceid and pr.projectid = rl.projectid";
lwstr=lwstr+" left join lateral(select case when count(*)=0 then 0 else 1 end as issub from pm_cbudgetsubplan sl join pm_cbudgetsubplan_resource sr on sr.planid = sl.pm_cbudgetsubplan_id where sl.cbudgetlistid = p.pm_cbudgetlist_id and sr.resourceid = r.projectrcjid) issub on true";
lwstr=lwstr+" where p.projectid = '"+projectid+"' and p.budgetunitid='"+cid+"' and pr.resourcetype = 1 and issub=0 ";
lwstr=lwstr+" ) as p group by projectid,budgetunitid,resourceid";
lwstr=lwstr+" ) as p";
lwstr=lwstr+" left join lateral(select pm_budgetunit_id,budgetunitname from pm_budgetunit where pm_project_id = p.projectid and pm_budgetunit_id = p.budgetunitid) bunitname on true";
lwstr=lwstr+" left join lateral(select pm_project_id,projectname from pm_project where pm_project_id = p.projectid) project on true";
//劳务
returnlist = GetServicesFunction.listSelectResultBySql([:],"VIEW_PM_MATERIALPLAN",lwstr,returncol);
bindField("LABORS",returnlist);
/****材料***/
returncol = [];
returncol.add("PROJECTID");
returncol.add("BUDGETUNITID");
returncol.add("WORKCONTENT");
returncol.add("RESOURCEID");
returncol.add("WORKLOAD");
returncol.add("UNITPRICE");
returncol.add("TOTALPRICE");
def clstr = " select projectid,budgetunitid,projectname||budgetunitname as workcontent,resourceid,workload,totalprice,unitprice";
clstr=clstr+" from(";
clstr=clstr+" select projectid,budgetunitid,resourceid,sum(workload) as workload,sum(totalprice) as totalprice,case when sum(workload)=0 then 0 else round(sum(totalprice)/sum(workload),2) end as unitprice";
clstr=clstr+" from(";
clstr=clstr+" select p.projectid,p.budgetunitid,rl.stuffid as resourceid,round(listwork*quotacontent*rcjcontent,4) as workload,round(listwork*quotacontent*rcjcontent*r.unitprice,2) as totalprice";
clstr=clstr+" from pm_cbudgetlist p";
clstr=clstr+" join lateral(select sum(engineeringquantity) as listwork from pm_cbudgetlistamount l where l.cbudgetlistid = p.pm_cbudgetlist_id) listwork on true";
clstr=clstr+" join pm_cbudgetquota q on p.pm_cbudgetlist_id=q.cbudgetlistid";
clstr=clstr+" join pm_cbudgetquotarcjcontent r on r.cbudgetquotaid = q.pm_cbudgetquota_id";
clstr=clstr+" join pm_projectresource pr on pr.pm_projectresource_id = r.projectrcjid";
clstr=clstr+" left join pm_stuffbudgetresource rl on pr.pm_projectresource_id = rl.resourceid and pr.projectid = rl.projectid";
clstr=clstr+" left join lateral(select case when count(*)=0 then 0 else 1 end as issub from pm_cbudgetsubplan sl join pm_cbudgetsubplan_resource sr on sr.planid = sl.pm_cbudgetsubplan_id where sl.cbudgetlistid = p.pm_cbudgetlist_id and sr.resourceid = r.projectrcjid) issub on true";
clstr=clstr+" where p.projectid = '"+projectid+"' and p.budgetunitid='"+cid+"' and pr.resourcetype = 2 and issub=0 ";
clstr=clstr+" ) as p group by projectid,budgetunitid,resourceid";
clstr=clstr+" ) as p";
clstr=clstr+" left join lateral(select pm_budgetunit_id,budgetunitname from pm_budgetunit where pm_project_id = p.projectid and pm_budgetunit_id = p.budgetunitid) bunitname on true";
clstr=clstr+" left join lateral(select pm_project_id,projectname from pm_project where pm_project_id = p.projectid) project on true";
returnlist = GetServicesFunction.listSelectResultBySql([:],"VIEW_PM_MATERIALPLAN",clstr,returncol);
bindField("MATERIALS",returnlist);
/****机械***/
returncol = [];
returncol.add("PROJECTID");
returncol.add("BUDGETUNITID");
returncol.add("WORKCONTENT");
returncol.add("RESOURCEID");
returncol.add("WORKLOAD");
returncol.add("UNITPRICE");
returncol.add("TOTALPRICE");
clstr = " select projectid,budgetunitid,projectname||budgetunitname as workcontent,resourceid,workload,totalprice,unitprice";
clstr=clstr+" from(";
clstr=clstr+" select projectid,budgetunitid,resourceid,sum(workload) as workload,sum(totalprice) as totalprice,case when sum(workload)=0 then 0 else round(sum(totalprice)/sum(workload),2) end as unitprice";
clstr=clstr+" from(";
clstr=clstr+" select p.projectid,p.budgetunitid,rl.stuffid as resourceid,round(listwork*quotacontent*rcjcontent,4) as workload,round(listwork*quotacontent*rcjcontent*r.unitprice,2) as totalprice";
clstr=clstr+" from pm_cbudgetlist p";
clstr=clstr+" join lateral(select sum(engineeringquantity) as listwork from pm_cbudgetlistamount l where l.cbudgetlistid = p.pm_cbudgetlist_id) listwork on true";
clstr=clstr+" join pm_cbudgetquota q on p.pm_cbudgetlist_id=q.cbudgetlistid";
clstr=clstr+" join pm_cbudgetquotarcjcontent r on r.cbudgetquotaid = q.pm_cbudgetquota_id";
clstr=clstr+" join pm_projectresource pr on pr.pm_projectresource_id = r.projectrcjid";
clstr=clstr+" left join pm_stuffbudgetresource rl on pr.pm_projectresource_id = rl.resourceid and pr.projectid = rl.projectid";
clstr=clstr+" left join lateral(select case when count(*)=0 then 0 else 1 end as issub from pm_cbudgetsubplan sl join pm_cbudgetsubplan_resource sr on sr.planid = sl.pm_cbudgetsubplan_id where sl.cbudgetlistid = p.pm_cbudgetlist_id and sr.resourceid = r.projectrcjid) issub on true";
clstr=clstr+" where p.projectid = '"+projectid+"' and p.budgetunitid='"+cid+"' and pr.resourcetype = 3 and issub=0 ";
clstr=clstr+" ) as p group by projectid,budgetunitid,resourceid";
clstr=clstr+" ) as p";
clstr=clstr+" left join lateral(select pm_budgetunit_id,budgetunitname from pm_budgetunit where pm_project_id = p.projectid and pm_budgetunit_id = p.budgetunitid) bunitname on true";
clstr=clstr+" left join lateral(select pm_project_id,projectname from pm_project where pm_project_id = p.projectid) project on true";
returnlist = GetServicesFunction.listSelectResultBySql([:],"VIEW_PM_MATERIALPLAN",clstr,returncol);
bindField("MACHINERYS",returnlist);
/****其他费用***/
returncol = [];
returncol.add("PROJECTID");
returncol.add("BUDGETUNITID");
returncol.add("WORKCONTENT");
returncol.add("RESOURCEID");
returncol.add("WORKLOAD");
returncol.add("TOTALPRICE");
clstr = " select pm_project_id as projectid,pm_budgetunit_id as budgetunitid,projectname||budgetunitname as workcontent,code as resourceid,value as totalprice";
clstr=clstr+" from(";
clstr=clstr+" SELECT code,value";
clstr=clstr+" FROM f_feecalc_getfeevalue(ARRAY(";
clstr=clstr+" select (q.pm_cbudgetquota_id,workload*quotacontent,q.unitprice,q.islist,feerategroupid)::pm_quota_engquantity as quotas";
clstr=clstr+" from pm_cbudgetquota q";
clstr=clstr+" join pm_cbudgetlist l on q.projectid = l.projectid and q.budgetunitid = l.budgetunitid and q.cbudgetlistid = l.pm_cbudgetlist_id";
clstr=clstr+" join lateral(select sum(engineeringquantity) as workload from pm_cbudgetlistamount la where la.cbudgetlistid = l.pm_cbudgetlist_id) workload on true";
clstr=clstr+" where q.projectid = '"+projectid+"' and q.budgetunitid = '"+cid+"'))";
clstr=clstr+" union all";
clstr=clstr+" select '023' as code,sum(round(workload*quotacontent*q.managementexpense,2))";
clstr=clstr+" from pm_cbudgetquota q";
clstr=clstr+" join pm_cbudgetlist l on q.projectid = l.projectid and q.budgetunitid = l.budgetunitid and q.cbudgetlistid = l.pm_cbudgetlist_id";
clstr=clstr+" join lateral(select sum(engineeringquantity) as workload from pm_cbudgetlistamount la where la.cbudgetlistid = l.pm_cbudgetlist_id) workload on true";
clstr=clstr+" left join lateral(select isincludemanagent from pm_cbudgetsubplan where cbudgetlistid = l.pm_cbudgetlist_id) mangent on true";
clstr=clstr+" where q.projectid = '"+projectid+"' and q.budgetunitid = '"+cid+"' and coalesce(isincludemanagent,0)!=1";
clstr=clstr+" union all";
clstr=clstr+" select '024' as code,sum(round(workload*quotacontent*q.drofit,2))";
clstr=clstr+" from pm_cbudgetquota q";
clstr=clstr+" join pm_cbudgetlist l on q.projectid = l.projectid and q.budgetunitid = l.budgetunitid and q.cbudgetlistid = l.pm_cbudgetlist_id";
clstr=clstr+" join lateral(select sum(engineeringquantity) as workload from pm_cbudgetlistamount la where la.cbudgetlistid = l.pm_cbudgetlist_id) workload on true";
clstr=clstr+" left join lateral(select isprofit from pm_cbudgetsubplan where cbudgetlistid = l.pm_cbudgetlist_id) mangent on true";
clstr=clstr+" where q.projectid = '"+projectid+"' and q.budgetunitid = '"+cid+"' and coalesce(isprofit,0)!=1";
clstr=clstr+" ) as p";
clstr=clstr+" left join lateral(select pm_budgetunit_id,budgetunitname from pm_budgetunit where pm_project_id = '"+projectid+"' and pm_budgetunit_id = '"+cid+"') bunitname on true";
clstr=clstr+" left join lateral(select pm_project_id,projectname from pm_project where pm_project_id = '"+projectid+"') project on true";
returnlist = GetServicesFunction.listSelectResultBySql([:],"VIEW_PM_MATERIALPLAN",clstr,returncol);
bindField("OTHERS",returnlist);
}
});