strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT,sum(OPXS) OPXS");
strSql.Append(",SUM(B.NETWEIGHT) AS NETWEIGHT,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",(B.NETWEIGHT) NETWEIGHT,(B.KGS) KGS,(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
//strSql.Append(" left join (select t3.* from (select *,row_number() over (partition by EDICODE order by portid asc) as rownum from code_disport) t3 where t3.rownum = 1 ) cd on B.DESTINATIONID = cd.EDICODE ");
strSql.Append(" left join (select * from( select *,row_number() over (partition by EDICODE order by CHAU desc) as rownum from (select EDICODE,COUNTRY,CHAU from code_disport union all select PORTENAME EDICODE,COUNTRY,'' CHAU from code_air_port)t4) t3 where t3.rownum = 1) cd on B.DESTINATIONID = cd.EDICODE ");
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.CUSTOMERNAME,C.[DESCRIPTION] "+bstype);
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT U.DEPTNAME SALEDEPT ");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
strSql.Append(" LEFT JOIN VW_user U ON (U.SHOWNAME=B.SALE) ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.OP, B.BSTYPE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.BSSOURCE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(" FROM V_OP_BS B ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where "+condition);
}
strSql.Append(" Group by B.BSSOURCE,B.BSSOURCEDETAIL ");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT B.LANE");
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
//strSql.Append(" left join (select t3.* from (select *,row_number() over (partition by EDICODE order by portid asc) as rownum from code_disport) t3 where t3.rownum = 1 ) cd on B.DESTINATIONID = cd.EDICODE ");
strSql.Append(" left join (select * from( select *,row_number() over (partition by EDICODE order by CHAU desc) as rownum from (select EDICODE,COUNTRY,CHAU from code_disport union all select PORTENAME EDICODE,COUNTRY,'' CHAU from code_air_port)t4) t3 where t3.rownum = 1) cd on B.DESTINATIONID = cd.EDICODE ");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) CNTR3");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) CNTR6");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) CNTR9");
strSql.Append(",SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) OTCNTR");
strSql.Append(",SUM(B.NETWEIGHT) NETWEIGHT,SUM(B.KGS) KGS,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) TEU");
condition=condition+" and isnull(B.ISCANCEL,0)<>1 ";
}
else
{
condition=" isnull(B.ISCANCEL,0)<>1 ";
}
}
varstrSql=newStringBuilder();
strSql.Append("SELECT ");
strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT");
strSql.Append(",SUM(B.NETWEIGHT) AS NETWEIGHT,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
strSql.Append("SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
str=" (B.OP='"+usercode+"' OR B.SALE='"+usercode+"' OR B.CUSTSERVICE='"+usercode+"')";
}
elseif(visiblerange=="2")
{
if(tb=="index")
{
varrangeDa=newRangeDA();
vardeptname=rangeDa.GetDEPTNAME(userid);
varuserstr=newStringBuilder();
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')");
str=" (B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
}
else
{
str=str+" or B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"' ";
};
}
str=str+")";
reader.Close();
}
}
else
{
str=" UPPER(B.Corpid)='"+companyid+"'";
}
}
elseif(visiblerange=="5")
{
varuserstr=newStringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
str=str+" or B.Corpid='"+Convert.ToString(reader["COMPANYID"])+"'";
};
}
str=str+")";
reader.Close();
}
}
elseif(visiblerange=="6")
{
varuserstr=newStringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='"+userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1");
str=" (B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
}
else
{
str=str+" or B.OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.SALE='"+Convert.ToString(reader["SHOWNAME"])+"' OR B.CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";