// === EIP4 P4 脚本迁移产出 === // template_id : 7d50dd37-9892-410e-9fdc-731f24fbfd80 // template_name: 项目成本拆分 // seq : 1 // label : HARD // 硬 S3 原因 : 动态创建 Vaadin Button(无法自动改写形态) // 处置 : 原文保留,进人工排期(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); } });