StringsqlGoods="SELECT ttt.*, ssoc.sCategoryDesc sTopOrgCategoryDesc, ssocc.sScopeTypeID sDefScopeTypeID, ssocc.sScopeType sDefScopeType FROM ( SELECT tt.*, ss.sCategoryDesc sTopCategoryDesc, soc.sUpCategoryNO sTopOrgCategoryNO, soc.sScopeTypeID sTopOrgScopeTypeID FROM ( SELECT t.nTag, t.nCaseUnits, t.sDistrictID, t.sWarehouseNO, t.sAgentContractNO, t.nGoodsID, t.sOrgNO, t.sGoodsDesc, t.sBrand, t.sBrandID, t.nAgentID, t.sMainBarcode, t.sSpec, t.sUnit, t.nMinSaleQty, t.nRealSalePrice, t.nSaleUnits, t.sOrgCategoryNO, t.sCategoryNO, t.sCategoryDesc, t.sUpCategoryNO, cc.sCategoryDesc sUpCategoryDesc, t.sOrgScopeType, t.sOrgScopeTypeID, t.sGoodsName, t.sAgentName, t.sURL, t.sWarehouseName, t.nRetailPrice, t.sRetailPriceUnit, t.sOrgCategoryDesc, t.sUpOrgCaregoryNO, t.nTotalSaleQty, cccc.sCategoryDesc sUpOrgCategoryDesc, cc.sUpCategoryNO sTopCategoryNO, oc.sScopeTypeID, oc.sScopeType, aso.nStockQty - aso.nLockedQty nStockQty, t.dCreateDate FROM ( SELECT awda.*, ogc.sCategoryNO sOrgCategoryNO, ogc.sCategoryDesc sOrgCategoryDesc, ogc.sUpCategoryNO sUpOrgCaregoryNO, ogc.sScopeType sOrgScopeType, ogc.sScopeTypeID sOrgScopeTypeID, g.sGoodsName, a.sAgentName, ( CASE WHEN agp.sURL IS NULL THEN p.sURL ELSE agp.sURL END ) sURL, w.sWarehouseName, gmp.nPrice nRetailPrice, gmp.sUnit sRetailPriceUnit, ccc.sCategoryDesc, ccc.sUpCategoryNO FROM ( SELECT GG.*, acg.nTag, acg.sOrgNO, acg.sGoodsDesc, acg.sBrand, acg.sBrandID, acg.nAgentID, acg.sMainBarcode, acg.sSpec, acg.sUnit, acg.nMinSaleQty, acg.nRealSalePrice, acg.nSaleUnits, acg.sCategoryNO, acg.nTotalSaleQty, acg.dCreateDate, acg.nCaseUnits FROM ( SELECT f1.sDistrictID, f1.sWarehouseNO, f1.sAgentContractNO, f1.nGoodsID, f2.nMaxDCPriority FROM ( SELECT wd.sDistrictID, wd.sWarehouseNO, acw.sAgentContractNO, acg.nGoodsID, wd.nDCPriority FROM tWarehouseDistrict wd LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO AND acw.nTag & 1 = 0 LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO AND acg.nTag & 1 = 0 WHERE wd.sDistrictID = '"+sIndexID+"' AND wd.nTag & 1 = 0 GROUP BY wd.sDistrictID, wd.sWarehouseNO, acw.sAgentContractNO, acg.nGoodsID, wd.nDCPriority ) f1, ( SELECT wd.sDistrictID, acw.sAgentContractNO, acg.nGoodsID, MIN (wd.nDCPriority) nMaxDCPriority FROM tWarehouseDistrict wd LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO AND acw.nTag & 1 = 0 LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO AND acg.nTag & 1 = 0 WHERE wd.sDistrictID = '"+sIndexID+"' AND wd.nTag & 1 = 0 GROUP BY wd.sDistrictID, acw.sAgentContractNO, acg.nGoodsID ) f2 WHERE f1.sDistrictID = f2.sDistrictID AND f1.sAgentContractNO = f2.sAgentContractNO AND f1.nGoodsID = f2.nGoodsID AND f1.nDCPriority = f2.nMaxDCPriority ) GG LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = GG.sAgentContractNO AND acg.nTag & 1 = 0 AND GG.nGoodsID = acg.nGoodsID ) awda LEFT JOIN ( SELECT ogcc.*, c.sCategoryDesc, c.sUpCategoryNO FROM tOrgGoodsCategory ogcc LEFT JOIN tCategory c ON c.sCategoryNO = ogcc.sCategoryNO AND c.nTag & 1 = 0 ) ogc ON ogc.sOrgNO = awda.sOrgNO AND ogc.nGoodsID = awda.nGoodsID LEFT JOIN tCategory ccc ON ccc.sCategoryNO = awda.sCategoryNO AND ccc.nTag & 1 = 0 LEFT JOIN tGoods g ON g.nGoodsID = awda.nGoodsID AND g.nTag & 1 = 0 LEFT JOIN tAgent a ON a.nAgentID = awda.nAgentID AND a.nTag & 1 = 0 LEFT JOIN tGoodsPic p ON p.nGoodsID = awda.nGoodsID AND p.nTag & 1 = 0 AND p.sPicTypeID = '1' AND p.nIdx = 1 LEFT JOIN tAgentGoodsPic agp ON agp.nAgentID = awda.nAgentID AND agp.nGoodsID = awda.nGoodsID AND agp.nTag & 1 = 0 AND agp.sPicTypeID = '1' AND agp.nIdx = 1 LEFT JOIN tWarehouse w ON w.sWarehouseNO = awda.sWarehouseNO AND w.nTag & 1 = 0 LEFT JOIN tGoodsMarketPrice gmp ON gmp.nGoodsID = awda.nGoodsID AND gmp.nTag & 1 = 0 AND gmp.sOrgNO = awda.sOrgNO WHERE awda.sAgentContractNO IS NOT NULL AND awda.nGoodsID IS NOT NULL AND awda.nTag & 1 = 0 AND awda.nTag & 256 = 0 ) t LEFT JOIN tCategory cc ON cc.sCategoryNO = t.sUpCategoryNO AND cc.nTag & 1 = 0 LEFT JOIN tCategory cccc ON cccc.sCategoryNO = t.sUpOrgCaregoryNO AND cccc.nTag & 1 = 0 LEFT JOIN tOrgCategory oc ON oc.sCategoryNO = t.sOrgCategoryNO AND oc.nTag & 1 = 0 AND oc.sOrgNO = t.sOrgNO LEFT JOIN tAgentStockOnline aso ON aso.nGoodsID = t.nGoodsID AND aso.sAgentContractNO = t.sAgentContractNO AND aso.sWarehouseNO = t.sWarehouseNO ) tt LEFT JOIN tCategory ss ON ss.sCategoryNO = tt.sTopCategoryNO AND ss.nTag & 1 = 0 LEFT JOIN tOrgCategory soc ON soc.sCategoryNO = tt.sUpOrgCaregoryNO AND soc.nTag & 1 = 0 AND soc.sScopeTypeID = tt.sOrgScopeTypeID AND soc.sOrgNO = tt.sOrgNO ) ttt LEFT JOIN tOrgCategory ssoc ON ssoc.sCategoryNO = ttt.sTopOrgCategoryNO AND ssoc.nTag & 1 = 0 AND ssoc.sScopeTypeID = ttt.sTopOrgScopeTypeID AND ssoc.sOrgNO = ttt.sOrgNO LEFT JOIN tOrgCategory ssocc ON ssocc.sCategoryNO = ttt.sCategoryNO AND ssocc.nTag & 1 = 0 AND ssocc.sOrgNO = ttt.sOrgNO WHERE ttt.sWarehouseName IS NOT NULL AND ttt.sWarehouseNO IS NOT NULL "+StringUtil.join(" AND "," AND ",strs);