strSql.Append(",CASE WHEN len(DESTINATIONID)<>5 THEN '' ELSE (select top 1 c_country_name from t_sys_country_code where c_country_code=LEFT(DESTINATIONID,2)) END as COUNTRY,EDI_TIME,VGM_TIME ");
strSql.Append(",STUFF((SELECT ',' + CNTRNO FROM op_ctn ctn WHERE ctn.BSNO = B.BSNO FOR xml path('')),1, 1, '') AS CNTRNOALL ");
strSql.Append(",STUFF((SELECT ',' + SEALNO FROM op_ctn ctn WHERE ctn.BSNO = B.BSNO FOR xml path('')),1, 1, '') AS SEALNOALL ");
strSql.Append(",(select ORDNO from crm_seaeorder where bsno=B.BSNO ) ORDNO");
strSql.Append(" from OP_SEAE B");
strSql.Append(" LEFT JOIN v_op_gain_dr_INV I ON (I.BSNO=B.BSNO) ");
strSql.Append(" left join (select bsno, sum(case when[status] = '海关放行' then 1 else 0 end) CUSTOMSSTATUS, sum(case when [status] = '运抵报告' then 1 else 0 end) HGYDSTATUS , sum(case when[status] = '码头放行' then 1 else 0 end) PORTSTATUS");
strSql.Append(",CASE WHEN len(DESTINATIONID)<>5 THEN '' ELSE (select top 1 c_country_name from t_sys_country_code where c_country_code=LEFT(DESTINATIONID,2)) END as COUNTRY,EDI_TIME,VGM_TIME ");
strSql.Append(",STUFF((SELECT ',' + CNTRNO FROM op_ctn ctn WHERE ctn.BSNO = B.BSNO FOR xml path('')),1, 1, '') AS CNTRNOALL ");
strSql.Append(",STUFF((SELECT ',' + SEALNO FROM op_ctn ctn WHERE ctn.BSNO = B.BSNO FOR xml path('')),1, 1, '') AS SEALNOALL ");
strSql.Append(",(select ORDNO from crm_seaeorder where bsno=B.BSNO ) ORDNO");
this.sqlCustcontext=" ((TYPE='2' AND GID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"')) OR (TYPE='1' AND GID IN (SELECT deptgid FROM VW_user WHERE USERID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"'))) "
+" OR (TYPE='0' AND GID IN (SELECT COMPANYID FROM VW_user WHERE USERID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"'))) )";
this.sqlCustcontext=" ((TYPE='2' AND GID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"')) OR (TYPE='1' AND GID IN (SELECT deptgid FROM VW_user WHERE USERID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"'))) "
+" OR (TYPE='0' AND GID IN (SELECT COMPANYID FROM VW_user WHERE USERID IN (SELECT USERID FROM info_client_range WHERE SHORTNAME='"+record.data.SHORTNAME+"'))) )";
sql=sql+getAndConSql(sql,MblNo,"(B.MblNo like '%"+MblNo+"%' or B.CONTRACTNO like '%"+MblNo+"%' or B.CUSTNO like '%"+MblNo+"%' or B.HBLNO like '%"
+MblNo+"%' or B.ORDERNO like '%"+MblNo+"%' or B.APPLYNO like '%"+MblNo+"%' or B.SERVICECONTRACTNO like '%"+MblNo+"%' )");
+MblNo+"%' or B.ORDERNO like '%"+MblNo+"%' or B.APPLYNO like '%"+MblNo+"%' or B.SERVICECONTRACTNO like '%"+MblNo+"%' or exists (select 1 from crm_seaeorder where ORDNO like '%" +MblNo+"%' and BSNO= OP_SEAE.BSNO) )");
this.storeConsignee.load({params:{condition:"shippertype=1 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='"+CUSTOMERNAME+"') )"},
this.storenotifyparty.load({params:{condition:"shippertype=3 AND (ISPUBLIC=1 OR CODENAME IN (SELECT CODENAME FROM info_client WHERE SHORTNAME='"+CUSTOMERNAME+"') )"},