|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 利润报表查询
|
|
|
/// </summary>
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsRptLhRptListController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET: /MvcShipping/MsRptOpProfit
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult LhCustCrStlDateIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
//
|
|
|
// GET:/RptMng/MsRptPcHeadQry/QryData
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult LhRptListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
|
|
|
{
|
|
|
//var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
//if (!string.IsNullOrEmpty(strDa))
|
|
|
//{
|
|
|
// if (!string.IsNullOrEmpty(condition))
|
|
|
// {
|
|
|
// condition = condition + " and " + strDa;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// condition = strDa;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT * ");
|
|
|
strSql.Append(" FROM V_LH_HK_ALL B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME,OPDATE");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME,OPDATE");
|
|
|
|
|
|
}
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult LhRptListBsData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT *,HKDAYS-HKDAYSCR ZYDAYS,case when YEARRATE=0 then 0 else STLTTL*YEARRATE/100/365*(HKDAYS-HKDAYSCR) end SJZYCB from (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT BSNO,OPTYPE,OPLBNAME,CUSTOMERNAME,CUSTNO,MBLNO,SALE,OPDATE,ACCDATE,CARRIER,BSSOURCE,BSSOURCEDETAIL,NOTAXTTLPROFIT,BSSTATUS,LANE,FORWARDER,YEARRATE ");
|
|
|
strSql.Append(" ,SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMB ");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSD");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTL");
|
|
|
strSql.Append(" ,SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMBCR ");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSDCR");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTLCR");
|
|
|
strSql.Append(", CAST(ROUND(CASE WHEN SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END, 0) AS INT) HKDAYS ");
|
|
|
strSql.Append(", CAST(ROUND(CASE WHEN SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END, 0) AS INT) HKDAYSCR ");
|
|
|
|
|
|
strSql.Append(" FROM v_fee_do_settlement_lh B");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
strSql.Append(" GROUP BY BSNO,OPTYPE,OPLBNAME,CUSTOMERNAME,CUSTNO,MBLNO,SALE,OPDATE,ACCDATE,CARRIER,BSSOURCE,BSSOURCEDETAIL,NOTAXTTLPROFIT,BSSTATUS,LANE,FORWARDER ,YEARRATE ) as v ");
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME,OPDATE");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME,OPDATE");
|
|
|
|
|
|
}
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult CustomerNameLhRptListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT CUSTOMERNAME ");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END) STLRMB ");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END) STLUSD");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END) STLTTL");
|
|
|
strSql.Append(",CASE WHEN SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END)/SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END) END HKDAYS");
|
|
|
strSql.Append(",SUM(BLCR) ZYCB");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*YEARRATE/365*INTERESTDAYS ELSE ORIGAMOUNT*EXRATE*YEARRATE/365*INTERESTDAYS END)CQLX");
|
|
|
strSql.Append(" FROM v_fee_do_settlement_lh_dr B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY CUSTOMERNAME ");
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTOMERNAME");
|
|
|
|
|
|
}
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult CustNameLhRptListData(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT CUSTNAME ");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END) STLRMB ");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END) STLUSD");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END) STLTTL");
|
|
|
strSql.Append(",CASE WHEN SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END)/SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END) END HKDAYS");
|
|
|
strSql.Append(",SUM(BLCR) ZYCB");
|
|
|
strSql.Append(",SUM(CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*YEARRATE/365*INTERESTDAYS ELSE ORIGAMOUNT*EXRATE*YEARRATE/365*INTERESTDAYS END)CQLX");
|
|
|
strSql.Append(" FROM v_fee_do_settlement_lh_dr B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY CUSTNAME ");
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTNAME");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by CUSTNAME");
|
|
|
|
|
|
}
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult BsListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
var NORPTSTLDATETYPE = MsSysParamSetDAL.GetData("PARAMNAME='NORPTSTLDATETYPE'");
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT *,dbo.F_FeeStatusStr(DRFEESTATUS) DRFEESTATUSREF,dbo.F_FeeStatusStr(CRFEESTATUS) CRFEESTATUSREF ");
|
|
|
strSql.Append(",case OPDATE when '' then 0 else case when BALTTLDR<>0 OR BALTTLCR<>0 then DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,GETDATE()) ");
|
|
|
strSql.Append(" else (DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,SETTLETIME)) end end AS NODAY");
|
|
|
strSql.Append(" FROM (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT B.BSNO,B.OPTYPE, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append("case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
strSql.Append(",case B.ETA when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETA,23) end as ETA,case B.ATD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ATD,23) end as ATD");
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.CUSTOMERNAME=F.CUSTOMERNAME THEN B.STLNAME ELSE isnull((select top 1 ACCTYPE from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),'现结买单') END STLNAME");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",B.STLNAME STLNAME");
|
|
|
}
|
|
|
|
|
|
strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP");
|
|
|
strSql.Append(",(CASE B.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,B.AGENTID ");
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME,H.HKDAYS ");
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
|
|
|
strSql.Append(",case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end) ");
|
|
|
strSql.Append(" else (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, S.SETTLETIME) end) end AS ACTUALDAY,S.SETTLETIME");
|
|
|
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",[dbo].[GetCustStlDay](B.OPDATE,F.CUSTOMERNAME,B.SALE) AS STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.STLDATE IS NULL THEN B.OPDATE ELSE B.STLDATE END STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =B.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (PROFITRATEDR.PARAMVALUE != "1")
|
|
|
{
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var FEEDEBITINVISMUST = MsSysParamSetDAL.GetData("PARAMNAME='RPTNOINVOICENO'");
|
|
|
if (FEEDEBITINVISMUST.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
if (condition.IndexOf("F.FEETYPE=1") >= 0)
|
|
|
{
|
|
|
// strSql.Append(",INVOICENO = stuff ((SELECT distinct INVOICENUM+',' FROM CH_FEE AS t WHERE ISNULL(t.INVOICENUM,'')<>'' AND t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct i.INVOICENO+',' FROM CH_FEE_DO AS t left join ch_fee_invoice i on (i.BILLNO=t.BILLNO) WHERE t.CATEGORY=7 and t .BSNO = B.BSNO and i.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct BILLNO+',' FROM CH_FEE_DO AS t WHERE t.CATEGORY=4 and t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else strSql.Append(",'' INVOICENO");
|
|
|
|
|
|
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN V_BSNO_HKDAY H ON (H.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C WITH (NOLOCK) ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN V_MAX_SETTLEMENTTIME S ON (S.CUSTOMERNAME=F.CUSTOMERNAME AND S.BSNO=B.BSNO) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append(" B.ETD,B.ETA,B.ATD");
|
|
|
strSql.Append(" ,B.OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(" ,B.CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(" ,B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(" ,B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,B.STLDATE,F.CUSTOMERNAME,C.[DESCRIPTION] ");
|
|
|
strSql.Append(",B.STLNAME,B.AGENTID");
|
|
|
|
|
|
strSql.Append(" , S.SETTLETIME,H.HKDAYS");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(") AS T ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
}
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult BsCrListData(int start, int limit, string condition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
var NORPTSTLDATETYPE = MsSysParamSetDAL.GetData("PARAMNAME='NORPTSTLDATETYPE'");
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("SELECT *,dbo.F_FeeStatusStr(DRFEESTATUS) DRFEESTATUSREF,dbo.F_FeeStatusStr(CRFEESTATUS) CRFEESTATUSREF ");
|
|
|
strSql.Append(",case OPDATE when '' then 0 else case when BALTTLDR<>0 OR BALTTLCR<>0 then DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,GETDATE()) ");
|
|
|
strSql.Append(" else (DATEDIFF([day],CASE WHEN STLDATE IS NULL THEN OPDATE ELSE STLDATE END,SETTLETIME)) end end AS NODAY");
|
|
|
strSql.Append(" FROM (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT B.BSNO,B.OPTYPE, B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append("case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD");
|
|
|
strSql.Append(",case B.ETA when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETA,23) end as ETA,case B.ATD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ATD,23) end as ATD");
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.CUSTOMERNAME=F.CUSTOMERNAME THEN B.STLNAME ELSE isnull((select top 1 ACCTYPE from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),'现结买单') END STLNAME");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",B.STLNAME STLNAME");
|
|
|
}
|
|
|
|
|
|
strSql.Append(",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP");
|
|
|
strSql.Append(",(CASE B.FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF,B.AGENTID ");
|
|
|
strSql.Append(",F.CUSTOMERNAME AS CUSTNAME ");
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME,H.HKDAYS ");
|
|
|
strSql.Append(",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS ORDERRMBCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(ORDERAMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS ORDERUSDCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(ORDERAMOUNT,0) END) END)ELSE 0 END),0) AS ORDEROTCR,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'RMB' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVRMB,");
|
|
|
strSql.Append("isnull(SUM(CASE CURRENCY WHEN 'USD' THEN ISNULL(INVOICE,0) ELSE 0 END),0) AS INVUSD,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS TTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS STLTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS BALTTLCR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 1 THEN cast(round(ISNULL(ORDERAMOUNT,0) * ISNULL(EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLDR,");
|
|
|
strSql.Append("isnull(SUM(CASE FEETYPE WHEN 2 THEN cast(round(ISNULL(ORDERAMOUNT,0) *ISNULL( EXCHANGERATE,0),2) as numeric(20,2)) ELSE 0 END),0) AS ORDERTTLCR");
|
|
|
|
|
|
strSql.Append(",case when isnull(SUM(F.AMOUNT),0)<>isnull(SUM(F.SETTLEMENT),0) then (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, GETDATE()) end) ");
|
|
|
strSql.Append(" else (case B.OPDATE when '1900-01-01 00:00:00.000' then 0 else DATEDIFF([day],B.OPDATE, S.SETTLETIME) end) end AS ACTUALDAY,S.SETTLETIME");
|
|
|
|
|
|
if (NORPTSTLDATETYPE.PARAMVALUE == "1")
|
|
|
{
|
|
|
strSql.Append(",[dbo].[GetCustStlDay](B.OPDATE,F.CUSTOMERNAME,B.SALE) AS STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =F.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",CASE WHEN B.STLDATE IS NULL THEN B.OPDATE ELSE B.STLDATE END STLDATE");
|
|
|
strSql.Append(",isnull((select top 1 case ACCTYPE WHEN '月结' then accmonth*30 + accdays WHEN '季结' then accmonth*90 + accdays WHEN '旬结' then 10 else accdays end from Info_Client_ACCDATE where LINKGID = (select top 1 GID from info_client where shortname =B.CUSTOMERNAME ) AND ((ISNULL(SALE,'')='') or (ISNULL(SALE,'')=B.SALE)) and BGNDATE<=B.OPDATE AND ENDDATE>=B.OPDATE),0) CONTRACTDAY ");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (PROFITRATEDR.PARAMVALUE != "1")
|
|
|
{
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var FEEDEBITINVISMUST = MsSysParamSetDAL.GetData("PARAMNAME='RPTNOINVOICENO'");
|
|
|
if (FEEDEBITINVISMUST.PARAMVALUE == "1")
|
|
|
{
|
|
|
|
|
|
if (condition.IndexOf("F.FEETYPE=1") >= 0)
|
|
|
{
|
|
|
// strSql.Append(",INVOICENO = stuff ((SELECT distinct INVOICENUM+',' FROM CH_FEE AS t WHERE ISNULL(t.INVOICENUM,'')<>'' AND t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct i.INVOICENO+',' FROM CH_FEE_DO AS t left join ch_fee_invoice i on (i.BILLNO=t.BILLNO) WHERE t.CATEGORY=7 and t .BSNO = B.BSNO and i.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",INVOICENO = stuff ((SELECT distinct BILLNO+',' FROM CH_FEE_DO AS t WHERE t.CATEGORY=4 and t .BSNO = B.BSNO and t.CUSTOMERNAME=f.CUSTOMERNAME FOR xml path('')), 1, 0, '') ");
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else strSql.Append(",'' INVOICENO");
|
|
|
|
|
|
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS");
|
|
|
|
|
|
strSql.Append(" FROM CH_FEE F WITH (NOLOCK) ");
|
|
|
strSql.Append(" INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN V_BSNO_HKDAYCR H ON (H.BSNO=B.BSNO) ");
|
|
|
strSql.Append(" LEFT JOIN info_client C WITH (NOLOCK) ON (C.SHORTNAME=F.CUSTOMERNAME) ");
|
|
|
strSql.Append(" LEFT JOIN V_MAX_SETTLEMENTTIME S ON (S.CUSTOMERNAME=F.CUSTOMERNAME AND S.BSNO=B.BSNO) ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.BLISSUESTATUS,B.BLTYPE,");
|
|
|
strSql.Append(" B.ETD,B.ETA,B.ATD");
|
|
|
strSql.Append(" ,B.OPDATE,B.ENTERP,B.DELIVERYDATE");
|
|
|
strSql.Append(" ,B.CUSTOMDATE,B.SERVICECONTRACTNO");
|
|
|
strSql.Append(" ,B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID");
|
|
|
strSql.Append(" ,B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.FEESTATUS,B.PKGS,B.CBM,B.ORDERNO,B.SALECORPID,B.STLDATE,F.CUSTOMERNAME,C.[DESCRIPTION] ");
|
|
|
strSql.Append(",B.STLNAME,B.AGENTID");
|
|
|
|
|
|
strSql.Append(" , S.SETTLETIME,H.HKDAYS");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(") AS T ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by CUSTNAME,OPDATE,MBLNO ");
|
|
|
}
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
}
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult OpXsSumListData(int start, int limit, string condition, string sort, string printstr)
|
|
|
{
|
|
|
var strDa = GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
|
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(" FROM v_op_bs_opxs B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult OpXsListData2(int start, int limit, string condition, string sort, string printstr, string sortstr)
|
|
|
|
|
|
{
|
|
|
var strDa = GetOpXsRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT * ");
|
|
|
strSql.Append(" FROM v_op_seae_opxs B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by ETD DESC");
|
|
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = condition,
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
strSql.Append(" order by ETD DESC");
|
|
|
|
|
|
}
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult OpXsSumListData2(int start, int limit, string condition, string sort, string printstr)
|
|
|
{
|
|
|
var strDa = GetOpXsRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strDa))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
condition = condition + " and " + strDa;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
condition = strDa;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
|
strSql.Append("OP,sum(OPXS) OPXS");
|
|
|
|
|
|
strSql.Append(" FROM v_op_seae_opxs B ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" GROUP BY OP ");
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult SumListData(int start, int limit, string condition, string sort, string printstr)
|
|
|
{
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
// strSql.Append("SELECT SUM(ZYCB) ZYCB,SUM(CQLX) CQLX,SUM(STLRMB) STLRMB,SUM(STLUSD) STLUSD,SUM(STLTTL) STLTTL,SUM(STLRMBCR) STLRMBCR,SUM(STLUSDCR) STLUSDCR,SUM(STLTTLCR),SUM(HKDAYS) HKDAYS,SUM(HKDAYSCR) HKDAYSCR,SUM(ZYDAYS) ZYDAYS,SUM(SJZYCB) SJZYCB from (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT *,HKDAYS-HKDAYSCR ZYDAYS,case when YEARRATE=0 then 0 else STLTTL*YEARRATE/100/365*(HKDAYS-HKDAYSCR) end SJZYCB from (");
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT MAX(YEARRATE) YEARRATE");
|
|
|
strSql.Append(" ,SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMB ");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSD");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTL");
|
|
|
strSql.Append(" ,SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMBCR ");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSDCR");
|
|
|
strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTLCR");
|
|
|
strSql.Append(", CAST(ROUND(CASE WHEN SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END, 0) AS INT) HKDAYS ");
|
|
|
strSql.Append(", CAST(ROUND(CASE WHEN SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
strSql.Append("ELSE SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END, 0) AS INT) HKDAYSCR ");
|
|
|
strSql.Append(",SUM(BLCR) ZYCB,SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*YEARRATE/100/365*INTERESTDAYS ELSE ORIGAMOUNT*EXRATE*YEARRATE/100/365*INTERESTDAYS END ELSE 0 END)CQLX ");
|
|
|
|
|
|
strSql.Append(" FROM v_fee_do_settlement_lh B");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" Where " + condition);
|
|
|
}
|
|
|
// strSql.Append("GROUP BY BSNO,OPTYPE,OPLBNAME,CUSTOMERNAME,CUSTNO,MBLNO,SALE,OPDATE,ACCDATE,CARRIER,BSSOURCE,BSSOURCEDETAIL,NOTAXTTLPROFIT,BSSTATUS,LANE,FORWARDER ,YEARRATE ) as v ");
|
|
|
|
|
|
strSql.Append(" ) as Z ");
|
|
|
|
|
|
|
|
|
|
|
|
//strSql.Append("SELECT SUM(BLCR) ZYCB,SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*YEARRATE/100/365*INTERESTDAYS ELSE ORIGAMOUNT*EXRATE*YEARRATE/100/365*INTERESTDAYS END ELSE 0 END)CQLX");
|
|
|
//strSql.Append(" ,SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMB ");
|
|
|
//strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSD");
|
|
|
//strSql.Append(",SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTL");
|
|
|
//strSql.Append(" ,SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLRMBCR ");
|
|
|
//strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='USD' THEN ORIGAMOUNT ELSE 0 END ELSE 0 END) STLUSDCR");
|
|
|
//strSql.Append(",SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) STLTTLCR");
|
|
|
//strSql.Append(",SUM(STLTTL*YEARRATE/100/365*(");
|
|
|
//strSql.Append("CASE WHEN SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
//strSql.Append("ELSE SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END ");
|
|
|
//strSql.Append("-CASE WHEN SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
//strSql.Append("ELSE SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END ");
|
|
|
//strSql.Append(" )) SJZYCB");
|
|
|
|
|
|
|
|
|
//strSql.Append(", CASE WHEN SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
//strSql.Append("ELSE SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=1 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END HKDAYS ");
|
|
|
//strSql.Append(", CASE WHEN SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END)=0 THEN 0 ");
|
|
|
//strSql.Append("ELSE SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT*OVERDAYS ELSE ORIGAMOUNT*EXRATE*OVERDAYS END ELSE 0 END)/SUM(CASE WHEN FEETYPE=2 THEN CASE WHEN ORIGCURRENCY='RMB' THEN ORIGAMOUNT ELSE ORIGAMOUNT*EXRATE END ELSE 0 END) END HKDAYSCR ");
|
|
|
|
|
|
//strSql.Append(" FROM v_fee_do_settlement_lh B ");
|
|
|
//if (!string.IsNullOrEmpty(condition))
|
|
|
//{
|
|
|
// strSql.Append(" Where " + condition);
|
|
|
//}
|
|
|
|
|
|
// strSql.Append("GROUP BY BSNO,OPTYPE,OPLBNAME,CUSTOMERNAME,CUSTNO,MBLNO,SALE,OPDATE,ACCDATE,CARRIER,BSSOURCE,BSSOURCEDETAIL,NOTAXTTLPROFIT,BSSTATUS,LANE,FORWARDER ,YEARRATE ) as v ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//strSql.Append("SELECT ");
|
|
|
|
|
|
|
|
|
|
|
|
//strSql.Append("sum(STLRMB) STLRMB,sum(STLUSD) STLUSD,sum(STLTTL) STLTTL,sum(STLRMBCR) STLRMBCR,sum(STLUSDCR) STLUSDCR,sum(STLTTLCR) STLTTLCR");
|
|
|
//strSql.Append(",SUM(ZYCB) ZYCB,SUM(CQLX) CQLX");
|
|
|
//strSql.Append(" ,sum(HKDAYS) HKDAYS,sum(HKDAYSCR) HKDAYSCR,(sum(HKDAYS)-sum(HKDAYSCR)) ZYDAYS,case when YEARRATE=0 then 0 else sum(STLTTL)/YEARRATE*(sum(HKDAYS)-sum(HKDAYSCR)) end SJZYCB ");
|
|
|
//strSql.Append(" FROM V_LH_HK_ALL B ");
|
|
|
|
|
|
//if (!string.IsNullOrEmpty(condition))
|
|
|
//{
|
|
|
// strSql.Append(" Where " + condition);
|
|
|
//}
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = true,
|
|
|
Message = "完成",
|
|
|
Data = strSql.ToString()
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var dbparams = new List<CustomDbParamter>();
|
|
|
|
|
|
var paramps_sSQL = new CustomDbParamter();
|
|
|
paramps_sSQL.ParameterName = "@sSQL";
|
|
|
paramps_sSQL.DbType = DbType.String;
|
|
|
paramps_sSQL.Direction = ParameterDirection.Input;
|
|
|
paramps_sSQL.Value = strSql.ToString();
|
|
|
dbparams.Add(paramps_sSQL);
|
|
|
|
|
|
|
|
|
|
|
|
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
|
|
|
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
public static string GetOpXsRangDAStr(string tb, string userid, string usercode, string companyid)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='OpXsList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
string operaterange = "4";
|
|
|
string AUTHORITYID = "";
|
|
|
string VSSQL = "";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
VSSQL = Convert.ToString(reader["VSSQL"]);
|
|
|
break;
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (visiblerange == "4")
|
|
|
{
|
|
|
str = "1=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
|
|
|
str = " (B.OP='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptid = rangeDa.GetDEPTGID(userid);
|
|
|
str = $" exists(select 1 from vw_user where deptgid='{deptid}' and SHOWNAME in(B.OP)) ";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
|
|
|
str = $" exists(select 1 from vw_user where COMPANYID='{companyid}' and SHOWNAME in(B.OP)) ";
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
|
|
|
|
|
|
str = " EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (B.OP=U.SHOWNAME) AND P.userid='" + userid + "' and P.AUTHORITYID='" + AUTHORITYID + "' and P.VISIBLERANGE=1) ";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
public static string GetRangDAStr(string tb, string userid, string usercode, string companyid)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='modRptBsList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
string operaterange = "4";
|
|
|
string AUTHORITYID = "";
|
|
|
string VSSQL = "";
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
VSSQL = Convert.ToString(reader["VSSQL"]);
|
|
|
break;
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (visiblerange == "4")
|
|
|
{
|
|
|
str = "1=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
|
|
|
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "' OR B.CUSTSERVICE='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
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 + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
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 + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "5")
|
|
|
{
|
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or B.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "6")
|
|
|
{
|
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
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");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
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 if (visiblerange == "1")
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
VSSQL = VSSQL.Trim();
|
|
|
if (!string.IsNullOrEmpty(VSSQL))
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
{
|
|
|
str = str + " and (" + VSSQL + ") ";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " (" + VSSQL + ") ";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|