strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
strSql.Append(" ,(select isnull(ISAGENTCN,0) from info_client where shortname=B.AIRLINES) ISAGENTCN ");
strSql.Append(" ,(select CODENAME from info_client where shortname=B.AIRLINES) AIRLINESCODE,HDEMO ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
strSql.Append(" ,(select name from company where gid=CORPID) CORPREF ");
strSql.Append(" from OP_AIRN B ");
strSql.Append(" left join OP_AIRN_CARGO C on c.bsno =( CASE b.BLTYPE when '国内分单' then B.bsno else (select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') end) ");
strSql.Append(" left join Import_cargoName icn on icn.gid=c.CARGOGID ");
varsqlQuery=" select 编号 MFNO,case when isnull(分提单号,'')<>'' then 分提单号 else 主提单号 end MBLNO,case when isnull(分提单号,'')<>'' then 0 else 1 end ISMAIN from t_op_seae_edi ";
sqlQuery+=string.Format(" where EDI类型='CN' and {0}>='{1}' and {2}<'{3}' and isnull(申报状态,'')='' order by 录入日期 desc",queryfield,startdate,queryfield,enddate);
sqlQuery+=string.Format(" where isnull(分提单号,'')='' and EDI类型='CN' and {0}>='{1}' and {2}<'{3}' and isnull(申报状态,'')='' order by 录入日期 desc",queryfield,startdate,queryfield,enddate);
//sqlQuery += " and not exists (select 1 from op_seae_edi_status where mfno=op_seae_edi.mfno and statustext= '装载放行' ) and dbo.getblno(mfno) not in(select mblno from wlxx_mblno) order by " + queryfield;