|
楼主 |
发表于 2017-3-14 12:16:38
|
显示全部楼层
public static Table equeryWM_InGoodsRegister(String concept,String select,String from,String aggregate,String dataModel,String fnModel,String condition,List range,Boolean distinct,String idColumn,String filter,Integer limit,Integer offset,String columns,String orderBy,String aggregateColumns,Map variables){
Map<String, String> map = new HashMap<String, String>();
String sqlFilter ="1 = 1";
if (filter != null && !"".equals(filter)) {
sqlFilter = filter;
}
String sql="SELECT WM_InGoodsRegister AS fID, WM_InGoodsRegister.version AS version, WM_InGoodsRegister.fBizState AS fBizState, WM_InGoodsRegister.fBizNO AS fBizNO, WM_InGoodsRegister.fBizDate AS fBizDate, WM_InGoodsRegister.fNoticeCode AS fNoticeCode, WM_InGoodsRegister.fFactoryCode AS fFactoryCode, WM_InGoodsRegister.fFactoryName AS fFactoryName, WM_InGoodsRegister.fWHCode AS fWHCode, WM_InGoodsRegister.fConMan AS fConMan, WM_InGoodsRegister.fInDate AS fInDate, WM_InGoodsRegister.fInNumber AS fInNumber, WM_InGoodsRegister.fBreakNumber AS fBreakNumber, WM_InGoodsRegister.fNOTE AS fNOTE, WM_InGoodsRegister.fATTM AS fATTM, WM_InGoodsRegister.fCreatePerson AS fCreatePerson, WM_InGoodsRegister.fCreatePersonFID AS fCreatePersonFID, WM_InGoodsRegister.fCreatePersonID AS fCreatePersonID, WM_InGoodsRegister.fCreateTime AS fCreateTime, WM_InGoodsRegister.fSM_PSN AS fSM_PSN, WM_InGoodsRegister.fSM_PSNID AS fSM_PSNID, WM_InGoodsRegister.fSM_DT AS fSM_DT, WM_InGoodsRegister.fRV_PSN AS fRV_PSN, WM_InGoodsRegister.fRV_PSNID AS fRV_PSNID, WM_InGoodsRegister.fRV_DT AS fRV_DT, WM_InGoodsRegister.fRevisePerson AS fRevisePerson, WM_InGoodsRegister.fRevisePersonID AS fRevisePersonID, WM_InGoodsRegister.fReviseDate AS fReviseDate, WM_InGoodsRegister.fDEL_RSN AS fDEL_RSN, WM_SUM.fSUM AS fSUM FROM WM_InGoodsRegister WM_InGoodsRegister optional JOIN (SELECT WM_InNoticeMaster.fBizNO as bizNo, b.fMasterID, SUM (b.fNumber) AS fSUM FROM WM_InNoticeDetail b optional JOIN WM_InNoticeMaster WM_InNoticeMaster on b.fMasterID = WM_InNoticeMaster GROUP BY WM_InNoticeMaster.fBizNO, b.fMasterID) WM_SUM ON WM_SUM.bizNo = WM_InGoodsRegister.fNoticeCode WHERE " + sqlFilter + " ORDER BY WM_InGoodsRegister.fBizNO desc";
map.put("MSSQL", sql);
System.out.println(sql);
//计算出总记录数
int cnt = 0;
Table tCount = KSQL.select("SELECT count(WM_InGoodsRegister.fNoticeCode) AS cnt FROM WM_InGoodsRegister WM_InGoodsRegister optional JOIN (SELECT c.fBizNO, b.fMasterID, SUM (b.fNumber) AS fSUM FROM WM_InNoticeDetail b optional JOIN WM_InNoticeMaster c on b.fMasterID = c GROUP BY c.fBizNO, b.fMasterID) WM_SUM ON WM_SUM.fBizNO = WM_InGoodsRegister.fNoticeCode WHERE " + sqlFilter, variables, dataModel, null);
Iterator<Row> it1 = tCount.iterator();
if(it1.hasNext()){
Row r = it1.next();
cnt = r.getInt("cnt");
}
//加上offset和limit实现分页
Table table = KSQL.select(sql + " limit "+Integer.toString(offset)+","+Integer.toString(limit), variables, dataModel, null);
//设置总记录数
table.getProperties().put(Table.PROP_DB_COUNT, cnt);
return table;
}
本来是取得*,后来一直出错,我就把所有项目都取了 |
|