strSql.Append("SUM(G.RMBDR) as RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
//else
// strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT,SUM(G.RMBDR) as RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
strSql.Append(",SUM(CASE WHEN A.OPTYPE='普通货' THEN A.NETWEIGHT ELSE 0 END) AS NETWEIGHT,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN A.OPTYPE='普通货' AND (A.BLTYPE='整箱' OR A.BLTYPE='拼箱主票' OR A.BLTYPE='合票主票') THEN A.OTCNTR ELSE 0 END) AS OTCNTR");
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) AS NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票' OR B.BLTYPE='合票主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
strSql.Append(",SUM(ISNULL(G.USDDR-G.USDCR,0)) AS USDPROFIT,SUM(ISNULL(G.RMBDR-G.RMBCR,0)) AS RMBPROFIT,SUM(ISNULL(G.OTDR-G.OTCR,0)) AS OTPROFIT,SUM(ISNULL(G.TTLDR-G.TTLCR,0)) AS TTLPROFIT ");
strSql.Append(",SUM(ISNULL(G.RMBDR-G.STLRMBDR,0)) AS RMBNODR,SUM(ISNULL(G.USDDR-G.STLUSDDR,0)) AS USDNODR,SUM(ISNULL(G.OTDR-G.STLOTDR,0)) AS OTNODR,SUM(ISNULL(G.TTLDR-G.STLTTLDR,0)) AS TTLNODR");
strSql.Append(",SUM(ISNULL(G.RMBCR-G.STLRMBCR,0)) AS RMBNOCR,SUM(ISNULL(G.USDCR-G.STLUSDCR,0)) AS USDNOCR,SUM(ISNULL(G.OTCR-G.STLOTCR,0)) AS OTNOCR,SUM(ISNULL(G.TTLCR-G.STLTTLCR,0)) AS TTLNOCR");
strSqlCtnr.Append("update op_ctnmng_ctndetail set ISBERETURN=0 where CTNGID in(select CTNGID from op_ctnmng_detail where CTNGID IN ("+ids+") AND BSNO='"+BSNO+"')");