|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 利润报表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsRptOpProfitController : Controller
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// GET: /MvcShipping/MsRptOpProfit
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// GET:/RptMng/MsRptPcHeadQry/QryData
|
|
|
|
|
|
|
|
|
|
public ContentResult BsListData(int start, int limit, string condition, string feecondition, string sort, string printstr, string sortstr, string amendstr = "false")
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (amendstr == "true")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("SELECT B.BSNO, B.OPLB,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,");
|
|
|
|
|
strSql.Append("C.[DESCRIPTION] AS CUSTFULLNAME, ");
|
|
|
|
|
strSql.Append("B.ETD,B.PKGS,B.CBM,B.NETWEIGHT");
|
|
|
|
|
strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK");
|
|
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE");
|
|
|
|
|
strSql.Append(",case B.FEESTATUS when 1 then '锁定' else '未锁定' end as FEESTATUSREF");
|
|
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, 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");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) RMBDR,SUM(G.RMBCR) RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) USDDR,SUM(G.USDCR) USDCR,");
|
|
|
|
|
strSql.Append("SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) OTDR,SUM(G.OTCR) OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) TTLDR,");
|
|
|
|
|
strSql.Append("SUM(G.TTLCR) TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
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");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) NOTAXRMBDR,SUM(G.NOTAXRMBCR) NOTAXRMBCR,SUM(G.NOTAXUSDDR) NOTAXUSDDR,SUM(G.NOTAXUSDCR) NOTAXUSDCR,SUM(G.NOTAXOTDR) NOTAXOTDR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXOTCR) NOTAXOTCR,SUM(G.NOTAXTTLDR) NOTAXTTLDR,SUM(G.NOTAXTTLCR) NOTAXTTLCR,SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
strSql.Append(" FROM V_OP_BS B ");
|
|
|
|
|
strSql.Append("LEFT JOIN V_OP_BILL A ON (A.PARENTID=B.BSNO) ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=A.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=A.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO, B.OPLB,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,");
|
|
|
|
|
strSql.Append("C.[DESCRIPTION] , ");
|
|
|
|
|
strSql.Append("B.ETD,B.PKGS,B.CBM,B.NETWEIGHT");
|
|
|
|
|
strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK");
|
|
|
|
|
strSql.Append(",B.CUSTOMDATE");
|
|
|
|
|
strSql.Append(",B.FEESTATUS");
|
|
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, 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");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append("SELECT B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,");
|
|
|
|
|
strSql.Append("C.[DESCRIPTION] AS CUSTFULLNAME, ");
|
|
|
|
|
strSql.Append("B.ETD,B.PKGS,B.CBM,B.NETWEIGHT");
|
|
|
|
|
strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK");
|
|
|
|
|
strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE");
|
|
|
|
|
strSql.Append(",case B.FEESTATUS when 1 then '锁定' else '未锁定' end as FEESTATUSREF");
|
|
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.CNTRTOTAL,B.CORPID");
|
|
|
|
|
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",B.TRADETYPE,B.GOODSNAME,B.FEESTATUS");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) RMBDR,SUM(G.RMBCR) RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) USDDR,SUM(G.USDCR) USDCR,");
|
|
|
|
|
strSql.Append("SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) OTDR,SUM(G.OTCR) OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) TTLDR,");
|
|
|
|
|
strSql.Append("SUM(G.TTLCR) TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
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");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) NOTAXRMBDR,SUM(G.NOTAXRMBCR) NOTAXRMBCR,SUM(G.NOTAXUSDDR) NOTAXUSDDR,SUM(G.NOTAXUSDCR) NOTAXUSDCR,SUM(G.NOTAXOTDR) NOTAXOTDR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXOTCR) NOTAXOTCR,SUM(G.NOTAXTTLDR) NOTAXTTLDR,SUM(G.NOTAXTTLCR) NOTAXTTLCR,SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" GROUP BY B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,");
|
|
|
|
|
strSql.Append("C.[DESCRIPTION] , ");
|
|
|
|
|
strSql.Append("B.ETD,B.PKGS,B.CBM,B.NETWEIGHT");
|
|
|
|
|
strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK");
|
|
|
|
|
strSql.Append(",B.CUSTOMDATE");
|
|
|
|
|
strSql.Append(",B.FEESTATUS");
|
|
|
|
|
strSql.Append(",B.CUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, 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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.CUSTOMERNAME,B.OPLB,B.CREATETIME 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 B.CUSTOMERNAME,B.OPLB,B.CREATETIME 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 };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult CustListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bstype = "";
|
|
|
|
|
var RPTPROFITBYBSTYPE = MsSysParamSetDAL.GetData("PARAMNAME='RPTPROFITBYBSTYPE'");
|
|
|
|
|
if (RPTPROFITBYBSTYPE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
bstype = ",B.BSTYPE";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.CUSTOMERNAME" + bstype);
|
|
|
|
|
strSql.Append(",C.[DESCRIPTION] AS CUSTFULLNAME ");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" LEFT JOIN info_client C ON (C.SHORTNAME=B.CUSTOMERNAME) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.CUSTOMERNAME,C.[DESCRIPTION] " + bstype);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.CUSTOMERNAME");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.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 };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult CarrierListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bstype = "";
|
|
|
|
|
var RPTPROFITBYBSTYPE = MsSysParamSetDAL.GetData("PARAMNAME='RPTPROFITBYBSTYPE'");
|
|
|
|
|
if (RPTPROFITBYBSTYPE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
bstype = ",B.BSTYPE";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.CARRIER" + bstype);
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.CARRIER " + bstype);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.CARRIER");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.CARRIER");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ContentResult SaleListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SALERPTONLYSALE = MsSysParamSetDAL.GetData("PARAMNAME='SALERPTONLYSALE'");
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
if (SALERPTONLYSALE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("SELECT B.SALE");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("SELECT B.SALE, B.BSSOURCE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
if (SALERPTONLYSALE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" Group by B.SALE ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strSql.Append(" Group by B.SALE, B.BSSOURCE ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by B.SALE," + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (SALERPTONLYSALE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by B.SALE ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strSql.Append(" order by B.SALE, B.BSSOURCE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (SALERPTONLYSALE.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by B.SALE ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strSql.Append(" order by B.SALE, B.BSSOURCE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ContentResult DeptListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT U.DEPTNAME SALEDEPT ");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
strSql.Append(" LEFT JOIN VW_user U ON (U.SHOWNAME=B.SALE) ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by U.DEPTNAME ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by U.DEPTNAME," + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by U.DEPTNAME");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
Data = strSql.ToString()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
sortstring = sortstring.Replace("SALEDEPT", "U.DEPTNAME");
|
|
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by U.DEPTNAME");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ContentResult OpListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.OP, B.BSTYPE");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.OP, B.BSTYPE ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.OP, B.BSTYPE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.OP, B.BSTYPE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ContentResult BsSourceListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.BSSOURCE");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT,SUM(B.NETWEIGHT) AS NETWEIGHT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.BSSOURCE ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.BSSOURCE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.BSSOURCE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ContentResult BsSourceDetailListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.BSSOURCE,B.BSSOURCEDETAIL ");
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.BSSOURCE,B.BSSOURCEDETAIL");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ContentResult LaneListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT B.LANE");
|
|
|
|
|
strSql.Append(",COUNT(B.BSNO) AS BLCOUNT");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR1 ELSE 0 END) CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR2 ELSE 0 END) CNTR2,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR3 ELSE 0 END) CNTR3");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR4 ELSE 0 END) CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR5 ELSE 0 END) CNTR5,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR6 ELSE 0 END) CNTR6");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR7 ELSE 0 END) CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR8 ELSE 0 END) CNTR8,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR9 ELSE 0 END) CNTR9");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.CNTR10 ELSE 0 END) CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.OTCNTR ELSE 0 END) OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.KGS ELSE 0 END) KGS,SUM(CASE WHEN B.OPTYPE='普通货' THEN B.TEU ELSE 0 END) TEU");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR) AS RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) AS STLRMBDR,SUM(G.STLRMBCR) AS STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) AS STLUSDDR,SUM(G.STLUSDCR) AS STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) AS STLOTDR,SUM(G.STLOTCR) AS STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) AS STLTTLDR,SUM(G.STLTTLCR) AS STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" and " + condition);
|
|
|
|
|
}
|
|
|
|
|
strSql.Append(" Group by B.LANE ");
|
|
|
|
|
|
|
|
|
|
if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" order by " + sortstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strSql.Append(" order by B.LANE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "完成",
|
|
|
|
|
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 B.LANE");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ContentResult SumListData(int start, int limit, string condition, string feecondition, 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 RPTPRNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='RPTPRNOCANCEL'");
|
|
|
|
|
|
|
|
|
|
if (RPTPRNOCANCEL.PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
condition = condition + " and isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
condition = " isnull(B.ISCANCEL,0)<>1 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
|
|
|
|
|
strSql.Append("COUNT(DISTINCT B.BSNO) AS BLCOUNT,SUM(G.RMBDR) as RMBDR,SUM(G.RMBCR) AS RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) AS USDDR,SUM(G.USDCR) AS USDCR,SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) AS OTDR,SUM(G.OTCR) AS OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(G.TTLDR) AS TTLDR,SUM(G.TTLCR) AS TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(CASE WHEN B.OPTYPE='普通货' THEN B.NETWEIGHT ELSE 0 END) AS NETWEIGHT,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.TEU ELSE 0 END) AS TEU,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR1 ELSE 0 END) AS CNTR1,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR2 ELSE 0 END) AS CNTR2,");
|
|
|
|
|
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR3 ELSE 0 END) AS CNTR3,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR4 ELSE 0 END) AS CNTR4,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR5 ELSE 0 END) AS CNTR5,");
|
|
|
|
|
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR6 ELSE 0 END) AS CNTR6,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR7 ELSE 0 END) AS CNTR7,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR8 ELSE 0 END) AS CNTR8,");
|
|
|
|
|
strSql.Append("SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR9 ELSE 0 END) AS CNTR9,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.CNTR10 ELSE 0 END) AS CNTR10,SUM(CASE WHEN B.OPTYPE='普通货' AND (B.BLTYPE='整箱' OR B.BLTYPE='拼箱主票') THEN B.OTCNTR ELSE 0 END) AS OTCNTR");
|
|
|
|
|
strSql.Append(",SUM(G.USDDR-G.USDCR) AS USDPROFIT,SUM(G.RMBDR-G.RMBCR) AS RMBPROFIT,SUM(G.OTDR-G.OTCR) AS OTPROFIT,SUM(G.TTLDR-G.TTLCR) AS TTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.RMBDR-G.STLRMBDR) AS RMBNODR,SUM(G.USDDR-G.STLUSDDR) AS USDNODR,SUM(G.OTDR-G.STLOTDR) AS OTNODR,SUM(G.TTLDR-G.STLTTLDR) AS TTLNODR");
|
|
|
|
|
strSql.Append(",SUM(G.RMBCR-G.STLRMBCR) AS RMBNOCR,SUM(G.USDCR-G.STLUSDCR) AS USDNOCR,SUM(G.OTCR-G.STLOTCR) AS OTNOCR,SUM(G.TTLCR-G.STLTTLCR) AS TTLNOCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXRMBDR) AS NOTAXRMBDR,SUM(G.NOTAXRMBCR) AS NOTAXRMBCR,SUM(G.NOTAXUSDDR) AS NOTAXUSDDR,SUM(G.NOTAXUSDCR) AS NOTAXUSDCR,SUM(G.NOTAXOTDR) AS NOTAXOTDR,SUM(G.NOTAXOTCR) AS NOTAXOTCR,SUM(G.NOTAXTTLDR) AS NOTAXTTLDR,SUM(G.NOTAXTTLCR) AS NOTAXTTLCR");
|
|
|
|
|
strSql.Append(",SUM(G.NOTAXUSDDR-G.NOTAXUSDCR) AS NOTAXUSDPROFIT,SUM(G.NOTAXRMBDR-G.NOTAXRMBCR) AS NOTAXRMBPROFIT,SUM(G.NOTAXOTDR-G.NOTAXOTCR) AS NOTAXOTPROFIT,SUM(G.NOTAXTTLDR-G.NOTAXTTLCR) AS NOTAXTTLPROFIT ");
|
|
|
|
|
strSql.Append(",SUM(G.TTLTAXDR) AS TTLTAXDR,SUM(G.TTLTAXCR) AS TTLTAXCR,SUM(G.TTLTAXDR-G.TTLTAXCR) AS TTLTAXPROFIT");
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(" FROM V_OP_BILL B ");
|
|
|
|
|
if (!string.IsNullOrEmpty(feecondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append("LEFT JOIN (SELECT BSNO, sum(RMBDR) RMBDR,SUM(RMBCR) RMBCR,SUM(STLRMBDR) STLRMBDR,SUM(STLRMBCR) STLRMBCR,SUM(USDDR) USDDR");
|
|
|
|
|
strSql.Append(",SUM(USDCR) USDCR,SUM(STLUSDDR) STLUSDDR,SUM(STLUSDCR) STLUSDCR,SUM(OTDR) OTDR");
|
|
|
|
|
strSql.Append(",SUM(OTCR) OTCR,SUM(STLOTDR) STLOTDR,SUM(STLOTCR) STLOTCR,SUM(TTLTAXDR) TTLTAXDR,SUM(TTLTAXCR) TTLTAXCR");
|
|
|
|
|
strSql.Append(",SUM(TTLDR) TTLDR,SUM(TTLCR) TTLCR,SUM(STLTTLDR) STLTTLDR,SUM(STLTTLCR) STLTTLCR");
|
|
|
|
|
strSql.Append(",SUM(NOTAXRMBDR) NOTAXRMBDR,SUM(NOTAXRMBCR) NOTAXRMBCR,SUM(NOTAXUSDDR) NOTAXUSDDR ");
|
|
|
|
|
strSql.Append(",SUM(NOTAXUSDCR) NOTAXUSDCR,SUM(NOTAXOTDR) NOTAXOTDR,SUM(NOTAXOTCR) NOTAXOTCR,SUM(NOTAXTTLDR) NOTAXTTLDR,SUM(NOTAXTTLCR) NOTAXTTLCR");
|
|
|
|
|
strSql.Append(" FROM v_op_gain_sum_INV G");
|
|
|
|
|
strSql.Append(" Where " + feecondition);
|
|
|
|
|
strSql.Append("GROUP BY BSNO) G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE ISNULL(G.BSNO,'')<>'' ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) ");
|
|
|
|
|
strSql.Append(" WHERE 1=1 ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" AND " + 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 GetRangDAStr(string tb, string userid, string usercode, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");
|
|
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
|
|
strSql.Append(" where [NAME]='modProfitreportRange' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
|
|
|
|
|
|
|
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"]);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = "1=2";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
str = " (B.OP='" + usercode + "' OR B.SALE='" + 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"]) + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + 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"]) + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
str = str + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|