using System; using HcUtility.Core; using Newtonsoft.Json; using System.Collections.Generic; using System.Text; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.DAL.MsCodeOpDef; using DSWeb.EntityDA; namespace DSWeb.MvcShipping.Models.MsOp_InternalTrade { [JsonObject]//国升内贸业务 头表 public class MsOp_INTERNALTRADEmb : ModelObjectBillHead { public override Dictionary GetPKey() {//用于给扩展的动态数据提供主键字段名 var d = new Dictionary() { { "BSNO", ModelDBOprationType.All } }; return d; } public Dictionary SaveDic = new Dictionary(); private static string getBaseSql() { return @" SELECT Op_INTERNALTRADE.[BSNO],[MASTERNO],[CUSTOMERNAME],isnull([BSSTATUS],0)BSSTATUS,isnull([FEESTATUS],0)FEESTATUS,isnull([CONTAINERDAYS],0)CONTAINERDAYS,dbo.trimtime([BSDATE]) BSDATE,CREATOR,[ACCDATE],[MBLNO],[HBLNO],[CUSTNO],[STLNAME],dbo.trimdate([STLDATE]) [STLDATE],[BSSOURCE],[BSSOURCEDETAIL],[TRANSNO],[OP],[CUSTSERVICE],[SALE],(select top 1 showname from [user] where gid=SALE)[SALEREF],[OPERATOR],dbo.GetUSER(OP)OPREF,dbo.GetUSER(CUSTSERVICE)CUSTSERVICEREF,dbo.GetUSER(SALE)SALEEF,[CORPID],[SALEDEPT],[CARRIER],[VESSEL],[VOYNO],[PORTLOADID],[PORTLOAD],dbo.trimdate([ETD])ETD,dbo.trimdate([ETA])ETA,[YARD],[TRUCKER],[TRUCKNO],[CNTRNO],[SEALNO],[CTNALL],[PORTLOADSTORAGEPERIOD],[FBPPORTLOAD],[PORTLOADREMARK],[VIAID],[VIA],dbo.trimdate([VIA_ETA])[VIA_ETA],[VIA_VESSEL],[VIA_VOYNO],dbo.trimdate([VIA_ETD])[VIA_ETD],[VIA_STORAGEPERIOD],[VIA2ID],[VIA2],dbo.trimdate([VIA2_ETA])[VIA2_ETA],[VIA2_VESSEL],[VIA2_VOYNO],dbo.trimdate([VIA2_ETD])[VIA2_ETD],[VIA2_STORAGEPERIOD],[VIA3ID],[VIA3],dbo.trimdate([VIA3_ETA])[VIA3_ETA],[VIA3_VESSEL],[VIA3_VOYNO],dbo.trimdate([VIA3_ETD])[VIA3_ETD],[VIA3_STORAGEPERIOD],[VIA_MARK],[PORTDISCHARGEID],[PORTDISCHARGE],[PlACERECEIPT],[TRUCKER2],[TRUCKNO2],[CONSIGNEE],[CONSIGNEECONTACT],[CONSIGNEETEL],dbo.trimdate([DISPATCHDATE])[DISPATCHDATE],dbo.trimdate([DELIVERYDATE])[DELIVERYDATE],dbo.trimdate([RECEIVEDATE])[RECEIVEDATE],dbo.trimdate(LOADEDCTNRETURNDATE)LOADEDCTNRETURNDATE,dbo.trimdate( EMPTYCTNTOSHIPPERDATE)EMPTYCTNTOSHIPPERDATE,convert(bigint ,TIMEMARK)TIMEMARK ,(select top 1 NAME from company where GID = CORPID)CORPREF,DISCHARGEREMARK,(SELECT TOP 1 STATUS FROM OP_STATUS WHERE BSNO=Op_INTERNALTRADE.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS,(select TOP 1 COLOR FROM code_op_status_detail WHERE OPSTATUS = (CASE WHEN(SELECT TOP 1[STATUS] FROM OP_STATUS WHERE BSNO = Op_INTERNALTRADE.BSNO ORDER BY COMPTIME DESC, INPUTTIME DESC) is null THEN '接受委托' else (SELECT TOP 1[STATUS] FROM OP_STATUS WHERE BSNO = Op_INTERNALTRADE.BSNO ORDER BY COMPTIME DESC, INPUTTIME DESC) end))AS COLOR,dbo.F_GetBillDrFeeStatus(Op_INTERNALTRADE.BSNO) DRFEESTATUS,dbo.F_GetBillCrFeeStatus(Op_INTERNALTRADE.BSNO) CRFEESTATUS,isnull((select TTLDR from v_op_gain_dr_INV where BSNO=Op_INTERNALTRADE.bsno),0) TTLDR,isnull((select TTLINVDR from v_op_gain_dr_INV where BSNO=Op_INTERNALTRADE.bsno),0) TTLINVDR,'' DRINVSTATUS,LOADCTNDATE,LOADCTNKGS,LOADCARGOKGS,RETURNYARD,I_MBLNO from Op_INTERNALTRADE where 1=1 "; } /// /// 获取查询语句 含权限和分页 /// /// /// /// /// /// public string getSQL(int start, int limit,string strCondition, string userid, out int count, string sortstring="") { var rangestr = ""; if(!(start==0 && limit==1)) rangestr = BasicDataRefDAL.GetRangeCondition(BasicDataRefDAL.RangeType.Visable, "modOp_InternalTrade", userid, GetCompanyFieldName(),new string[] { "OP", "CUSTSERVICE", "SALE" }); var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = getBaseSql(); param.strCondition = strCondition; param.rangestr = rangestr; param.sortstring = sortstring; param.defaultsortstr = "ETD desc"; param.start = start; param.limit = limit; var result = BasicDataRefDAL.PagedQuaryStr(param); count = BasicDataRefDAL.PagedCount(param); return result.ToString(); } public string getSQL_all(int start, int limit, string strCondition,string sortstring = "") { var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = getBaseSql(); param.strCondition = strCondition; param.rangestr = ""; param.sortstring = sortstring; param.defaultsortstr = "CUSTNO"; param.start = start; param.limit = limit; var result = BasicDataRefDAL.PagedQuaryStr(param); return result.ToString(); } public MsOp_INTERNALTRADEmb() { TableName = "Op_INTERNALTRADE"; } public void getDef(string USERID) { //将一个数据对象的有默认值的数据项 设置为默认 var rangeDa = new RangeDA(); var CORPID = rangeDa.GetCORPID(USERID); var deflist = MsCodeOpDefDAL.getDefList("内贸管理", CORPID); if (deflist.Count > 0) { foreach (var defitem in deflist) { SetValue(defitem.FIELDNAME, defitem.DEFVALUE); } } SetValue("TIMEMARK", "0"); //设置一些数字字段的默认值: setNoNullDef("BSSTATUS"); setNoNullDef("FEESTATUS"); setNoNullDef("CONTAINERDAYS"); setNoNullDef("PORTLOADSTORAGEPERIOD"); setNoNullDef("FBPPORTLOAD"); setNoNullDef("VIA_STORAGEPERIOD"); setNoNullDef("VIA2_STORAGEPERIOD"); setNoNullDef("VIA3_STORAGEPERIOD"); setNoNullDef("LOADCTNKGS"); setNoNullDef("LOADCARGOKGS"); setNoNullDef("ACCDATE", DateTime.Now.ToString("yyyy-MM")); setNoNullDef("CORPID", CORPID); } public override string GetBillNoFieldName() { return "BSNO"; } public override string GetTimeMarkFieldName() { return "TIMEMARK"; } } [JsonObject]//押箱业务 明细表 public class MsOp_INTERNALTRADE_Detailmb : ModelObjectBillBody { public override Dictionary GetPKey() {//用于给扩展的动态数据提供主键字段名 var d = new Dictionary() { { "GID", ModelDBOprationType.All } }; return d; } public Dictionary SaveDic = new Dictionary(); public static string getSQL() { var result = @" SELECT [GID],D.[BSNO],[ORDERNO],[LOTNO],[GOODSNAME],[PACKEGS],dbo.trimdate([LOADDATE])LOADDATE,[LOADADDR],isnull([SEQUENCE],0)SEQUENCE " + " from Op_INTERNALTRADE_DETAIL D " + " left Join Op_INTERNALTRADE h on h.bsno = d.BSNO where 1=1 "; return result; } public MsOp_INTERNALTRADE_Detailmb() { TableName = "Op_INTERNALTRADE_DETAIL"; } public MsOp_INTERNALTRADE_Detailmb(string BSNO) { SetValue("BSNO", BSNO); TableName = "Op_INTERNALTRADE_DETAIL"; } public override string GetBillNoFieldName() { return "BSNO"; } public override string GetTimeMarkFieldName() { return ""; } } }