strSql.Append(",(SELECT TOP 1 STATUS+' '+ CONVERT(varchar(100),COMPTIME, 20) FROM OP_STATUS WHERE BSNO=v_op_bill.BSNO AND STTYPE='2' ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS ");
strSql.Append(",(SELECT TOP 1 COMMISSIONRATE FROM V_Client_ACCDATE WHERE SHORTNAME=v_op_bill.CUSTOMERNAME ORDER BY BGNDATE DESC) as COMMISSIONRATE ");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97008 and EnumValueID=cm.INVOICECATEGORY) as INVOICECATEGORYREF");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=97009 and EnumValueID=cm.INVOICETYPE) as INVOICETYPEREF");
strSql.Append(",(case cm.billstatus when 1 then '已锁定' else '未锁定' end) as BILLSTATUSREF");
strSql.Append(",(select ShowName from [user] where GID=cm.OPERATOR) as OPERATORNAME");
strSql.Append(",CREATEUSER,(select ShowName from [user] where GID=cm.CREATEUSER) as CREATEUSERREF,CREATETIME");
strSql.Append(",(select ShowName from [user] where GID=cm.DELETEOPERATOR) as DELOPERATORNAME");
strSql.Append(",dbo.GetFeeNoStlByInvNo(cm.BILLNO) as NOSTL,FEEAMOUNT,VOUNO,DZSTATUS");
strSql.Append(", INVSHENNO=stuff ((SELECT distinct BILLNO+',' FROM ch_fee_invoiceapplication p WHERE p.INVBILLNO=cm.BILLNO FOR xml path('')), 1, 0, '')");
strSql.Append(",(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO) APPLICANT");
strSql.Append(",(select top 1 (select DEPTNAME from [VW_user] where userid=ap.applicant) APPLICANTDEPT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO) APPLICANTDEPT");
strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP");
strSql.Append(",(select sum(TAX) from ch_fee_invoicedetail where PID=cm.GID) as TAX");
strSql.Append(",PTORRED,SETRED,INVAMOUNT-(select sum(TAX) from ch_fee_invoicedetail where PID=cm.GID) NOTAXAMOUNT");
strSql.Append(" FROM ch_fee_invoice cm where 1=1 ");
if(!string.IsNullOrEmpty(condition))
{
strSql.Append(" and "+condition);
}
strSql.Append(" order by CURRENCY,OPERATETIME DESC");
sql=sql+getAndConSql(sql,CustomNo,"BILLNO IN (SELECT BILLNO FROM CH_FEE_DO WHERE BSNO IN (SELECT BSNO FROM V_OP_BILL b WHERE b.CUSTNO like '%" +CustomNo+"%' or b.MBLNO like '%"+CustomNo+"%' or b.HBLNO like '%"+CustomNo+"%' or b.CUSTOMNO like '%"+CustomNo+"%' or b.ORDERNO like '%"+CustomNo+"%'))");
sql=sql+getAndConSql(sql,CustomNo,"BILLNO IN (SELECT BILLNO FROM CH_FEE_DO_INVOICE WHERE BSNO IN (SELECT BSNO FROM V_OP_BILL b WHERE b.CUSTNO like '%" +CustomNo+"%' or b.MBLNO like '%"+CustomNo+"%' or b.HBLNO like '%"+CustomNo+"%' or b.CUSTOMNO like '%"+CustomNo+"%' or b.ORDERNO like '%"+CustomNo+"%'))");
strSqlBs.Append(",B.操作员,B.销售部门 from t_op_seae B where ISNULL(B.是否占舱,'')<>'Y' And B.预抵日期>='" +enumFeeproject.ETDFR+"' and B.预抵日期<'"+enumFeeproject.ETDTO+"' ");
strSqlBs.Append(",B.操作员,B.销售部门 from t_op_seae B WITH (NOLOCK) where ISNULL(B.是否占舱,'')<>'Y' And B.预抵日期>='" +enumFeeproject.ETDFR+"' and B.预抵日期<'"+enumFeeproject.ETDTO+"' ");
if(querySql!="")
strSqlBs.Append(querySql);
@ -151,7 +151,7 @@ namespace JobCreateFee
{
varheadList=newList<MsClient>();
varstrSql=newStringBuilder();
strSql.Append("SELECT 客户简称,客户全称,客商编码 from t_crm_client ");
strSql.Append("SELECT 客户简称,客户全称,客商编码 from t_crm_client WITH (NOLOCK) ");
strSql.Append("SELECT '1' as NO,件数 PKGS,重量 KGS,尺码 CBM,重量 AS NETWEIGHT,0 AS FEEKGS,");
strSql.Append("'' as CTNALL,0 AS CTNNUM,0 AS TEU ");
strSql.Append(",isnull((select sum(数量) from t_op_ctn where 编号=t_op_seae.编号),0) 总箱数 ");
strSql.Append(",isnull((select sum(数量) from t_op_ctn WITH (NOLOCK) where 编号=t_op_seae.编号),0) 总箱数 ");
// strSql.Append(",isnull((select sum(ctnrCount) from t_op_txxp_log where 编号=t_op_seae.编号),0)-isnull((select sum(数量) from t_op_ctn where 编号=t_op_seae.编号),0) 超额小票数 ");
strSql.Append(" from t_op_seae ");
strSql.Append(" from t_op_seae WITH (NOLOCK) ");
strSql.Append(" where 编号='"+BSNO+"'");
strSql.Append(") AS T ");
@ -485,7 +486,7 @@ namespace JobCreateFee
strSql.Append(" union ");
strSql.Append("SELECT '2' AS NO,0 AS PKGS,0 AS KGS,0 AS CBM,0 AS NETWEIGHT,0 AS FEEKGS,");
strSql.Append("P.表现形式 CTNALL,SUM(P.数量) AS CTNNUM,SUM(P.TEU) AS TEU");
strSql.Append(" from t_op_ctn P ");
strSql.Append(" from t_op_ctn P WITH (NOLOCK) ");
strSql.Append(" where p.编号='"+BSNO+"'");
strSql.Append(" GROUP BY P.表现形式 order by PKGS desc");
@ -589,7 +590,7 @@ namespace JobCreateFee
{
decimalusdexrate=0;
varstrSql=newStringBuilder();
strSql.Append("select 汇率 from t_code_usdexrate where 开始日期<='"+etd+"' and 结束日期>='"+etd+"'");
strSql.Append("select 汇率 from t_code_usdexrate WITH (NOLOCK) where 开始日期<='"+etd+"' and 结束日期>='"+etd+"'");