|

楼主 |
发表于 2015-5-11 14:08:08
|
显示全部楼层
数据不是添加的,是自己写的SQL语句:
public static Table PCostRepPro(String filter){
String where = "";
if (filter != null) {
System.out.println("filter"+filter);
where = " and " + filter;
}
String perid = ContextHelper.getOperator().getID();
String sql = "select x.fID,x.PFidPC,x.PCodePC,x.PNamePC,x.aMon,x.bMon,x.cMon,(x.bMon+x.cMon) dMon,x.eaMon,x.ebMon,x.ecMon,x.edMon,x.eeMon,x.eMon,(x.bMon+x.cMon-x.eMon) fMon " +
"from (" +
"select p.fID,p.PFidPC,p.PCodePC,p.PNamePC," +
"(select (case when SUM(a.aMonCI) IS null then 0.00 else SUM(a.aMonCI) end) from PConInfor a where a.zMark='RECCON' and a.zAudit='已审核' and a.pFidCI= p.PFidPC) aMon," +
"(select (case when SUM(b.aMonRI) IS null then 0.00 else SUM(b.aMonRI) end) from PRecInfor b where b.zMark='RECVAL' and b.zAudit='已审核' and b.pFidRI= p.PFidPC) bMon," +
"(select (case when SUM(c.aMonRI) IS null then 0.00 else SUM(c.aMonRI) end) from PRecInfor c where c.zMark='RECVIS' and c.zAudit='已审核' and c.pFidRI= p.PFidPC) cMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC and e.TypeCW = '材料') eaMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC and e.TypeCW = '设备') ebMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC and e.TypeCW = '分包') ecMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC and e.TypeCW = '人工') edMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC and e.TypeCW = '费用') eeMon," +
"(select (case when SUM(e.aMonCW) IS null then 0.00 else SUM(e.aMonCW) end) from PCostWar e where e.pFidCW=p.PFidPC) eMon " +
"from PProCom p where p.CFidPC = '" + perid + "' " + where + " " +
") x order by x.PCodePC desc " ;
System.out.println("sql:"+sql);
return Common.queryTable(Common.brp_model, sql);
} |
|