You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
300 lines
46 KiB
Transact-SQL
300 lines
46 KiB
Transact-SQL
|
|
|
|
|
|
|
|
|
|
ALTER VIEW [dbo].[v_op_bs]
|
|
as
|
|
SELECT BSNO,MASTERNO, 'op_seae' AS OPLB, '海运出口' AS OPLBNAME,'海运出口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE, STLNAME, VESSEL, VOYNO, INPUTBY,BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE , OP , DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE,CUSTOMNO,
|
|
ACCDATE,CARRIER, BSSOURCE,BSSOURCEDETAIL, LANE, FORWARDER, 0 AS NETWEIGHT, KGS,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN TEU ELSE 0 END TEU, CNTRTOTAL,
|
|
CORPID,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR1 ELSE 0 END CNTR1,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR2 ELSE 0 END CNTR2,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR3 ELSE 0 END CNTR3, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR4 ELSE 0 END CNTR4,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR5 ELSE 0 END CNTR5,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR6 ELSE 0 END CNTR6,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR7 ELSE 0 END CNTR7, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR8 ELSE 0 END CNTR8,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR9 ELSE 0 END CNTR9,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR10 ELSE 0 END CNTR10,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN OTCNTR ELSE 0 END OTCNTR, '' AS TRADETYPE, GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,''BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,OPERATOR,SERVICECONTRACTNO,ISCANCEL
|
|
,APPLYNO,ISSUETYPE,BLISSUESTATUS,REMARK,TRADETERM,PLACERECEIPT,DESTINATION,CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,DESTINATIONID,SALECORPID,YARD,DELIVERYDATE,FRCUSTSERVICE,SERVICE,OPERATORFAX REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,CLOSINGDATE,KINDPKGS,CARGOID,DCLASS
|
|
FROM dbo.op_seae WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,MASTERNO, 'op_seai' AS OPLB, '海运进口' AS OPLBNAME,'海运进口' AS BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL, VOYNO, INPUTBY,BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE ,OP , DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO,ACCDATE,
|
|
CARRIER, BSSOURCE,BSSOURCEDETAIL, LANE, FORWARDER, NETWEIGHT, KGS,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN TEU ELSE 0 END TEU, CNTRTOTAL,
|
|
CORPID,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR1 ELSE 0 END CNTR1,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR2 ELSE 0 END CNTR2,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR3 ELSE 0 END CNTR3, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR4 ELSE 0 END CNTR4,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR5 ELSE 0 END CNTR5,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR6 ELSE 0 END CNTR6,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR7 ELSE 0 END CNTR7, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR8 ELSE 0 END CNTR8,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR9 ELSE 0 END CNTR9,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR10 ELSE 0 END CNTR10,
|
|
CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN OTCNTR ELSE 0 END OTCNTR, TRADETYPE, GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,CUSTOMDATE,ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,''BOOKNO,AGENTID,ISPRINTPR,NUMBERPLATE,0 FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,APPLYNO,ISSUETYPE,BLISSUESTATUS,REMARK,TRADETERM,PLACERECEIPT,DESTINATION,CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,DESTINATIONID,SALECORPID,YARD,TIHUOTIME DELIVERYDATE,FRCUSTSERVICE,SERVICE,REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,CARGOID,DCLASS
|
|
FROM dbo.op_seai WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,MASTERNO, 'op_aire' AS OPLB, '空运出口' AS OPLBNAME,'空运出口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE , OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO,
|
|
ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,LANE, FORWARDER, FEEKGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM ,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,DELIVERYDATE,FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_aire WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO, MASTERNO,'op_airi' AS OPLB, '空运进口' AS OPLBNAME,'空运进口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETA) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE ,OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE,CUSTOMNO,
|
|
ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,LANE, FORWARDER, FEEKGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME,
|
|
FEESTATUS,ETA AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID ,'' YARD,DELIVERYDATE,FRCUSTSERVICE,SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_airi WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO, MASTERNO,'op_apply' AS OPLB, '报关业务' AS OPLBNAME,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=OP_APPLY.BsType) as BSTYPE,CUSTOMERNAME, CUSTNO,'' ORDERNO, MBLNO, HBLNO, CUSTOMDATE as ETD,'' ETA
|
|
,'' STLDATE,'' STLNAME, VESSEL, VOYNO, INPUTBY,CUSTOMTYPE BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,TEU,'' CNTRTOTAL,
|
|
CORPID,CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,OPDATE,CUSTOMDATE,ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_apply WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO, BSNO MASTERNO,'op_other' AS OPLB, '综合业务' AS OPLBNAME,TRANSTYPE as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO, MBLNO, HBLNO, ETD,'' ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL, VOYNO,OP AS INPUTBY,'' BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_other WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,BSNO MASTERNO, 'op_bulk' AS OPLB, '大宗散货' AS OPLBNAME,TRANSTYPE as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,'' MBLNO,'' HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_bulk WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT ContractNo AS BSNO, ContractNo MASTERNO,'import_main' AS OPLB, '进口贸易' AS OPLBNAME,'进口贸易' AS BSTYPE, buyer AS CUSTOMERNAME, HTH AS CUSTNO,Supplier_Billno+' '+Other_Billno ORDERNO, billno as MblNo, M.ContainerNo AS HBLNO, dbo.trimdate(Arrivaldate) AS ETD,dbo.trimtime(M.ArrivalDate) ETA
|
|
,'' STLDATE,'' STLNAME, VESSEL,voyage as VOYNO, (select showname from [user] where codename=creator) AS INPUTBY,'' BLTYPE,
|
|
CREATTIME as CREATETIME,isnull(BSSTATUS,0) AS BSSTATUS, (select showname from [user] where codename=creator) AS SALE, OP AS OP, op AS DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) AS PORTDISCHARGE, '' AS CUSTOMNO,
|
|
case when isnull(ACCDATE,'')='' then '' else dbo.trimdate(ACCDATE) end ACCDATE ,
|
|
'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
isnull(FEESTATUS,0) FEESTATUS,Arrivaldate AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'',ISVOU,'' VOUNO ,'' DESTINATIONID,M.company SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,null BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.import_main M WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,MASTERNO, 'op_railway' AS OPLB, '铁路运输' AS OPLBNAME,'铁路运输' as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO,HBLNO,SETOUTDATE ETD,'' ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS, SALE, OP,'' DOC,CUSTSERVICE, PLACELOAD,DESTINATIONENAME AS PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,SETOUTDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO ,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,PLACERECEIPT,DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO,DESTINATIONENAME DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_railway WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT GId BSNO,GId MASTERNO, 'tMsWlPcHead' AS OPLB, '陆运派车单' AS OPLBNAME,'陆运派车单' as BSTYPE,CUSTOMERNAME,Billno CUSTNO,'' ORDERNO,MBLNO MBLNO,'' HBLNO,dbo.trimdate(ExpDate) ETD,dbo.trimdate(RtnDocTime) ETA
|
|
,'' STLDATE,'' STLNAME,TruckNo VESSEL,(select top 1 DrvName from tMsWlDriver where DrvCode=dbo.tMsWlPcHead.DrvCode) VOYNO,(select top 1 showname from [user] where CODENAME=DdCode) INPUTBY, BLTYPE,
|
|
'' CREATETIME,BillStatus BSSTATUS,SalesName SALE,case isnull(UserName,'') when '' then (select top 1 showname from [user] where CODENAME=DdCode) else UserName end OP,'' DOC,'' CUSTSERVICE,LoadPlace PLACELOAD,DstArea PORTDISCHARGE,'' CUSTOMNO,
|
|
case when dbo.trimdate(ExpDate)<>'' then LEFT(dbo.trimdate(ExpDate),7) else '' end ACCDATE ,'' CARRIER,'' BSSOURCE,'' BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,
|
|
(select top 1 Ctn from code_ctn where CtnId=dbo.tMsWlPcHead.ContainerType)+'*'+convert(varchar(20),dbo.tMsWlPcHead.ContainerQty) CNTRTOTAL,
|
|
(select top 1 GID from company where codename=dbo.tMsWlPcHead.orgcode) CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,dbo.trimdate(ExpDate) OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,RtnDocStatus BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,DstArea DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.tMsWlPcHead WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT F_NO AS BSNO,F_NO MASTERNO, 'import_finance' AS OPLB, '贸易融资' AS OPLBNAME,'贸易融资' AS BSTYPE, CUSTOMER AS CUSTOMERNAME, F_NO AS CUSTNO,f.HTH ORDERNO, F.Billno MblNo,'' HBLNO, STARTDATE AS ETD,'' ETA
|
|
,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO, (select showname from [user] where gid=M.OP) AS INPUTBY,'' BLTYPE,
|
|
ENTERDATE as CREATETIME, 0 BSSTATUS, '' AS SALE, (select showname from [user] where gid=M.OP) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, '' AS CUSTOMNO,
|
|
case when isnull(STARTDATE,'')='' then '' else dbo.trimdate(STARTDATE) end ACCDATE ,
|
|
'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
'' CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
0 FEESTATUS,STARTDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,'' REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,'' ,M.ISVOU,'' VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,null BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.IMPORT_FINANCE M WITH (NOLOCK)
|
|
left join [dbo].[Import_main] f on (f.ContractNo=M.MAINNO)
|
|
UNION ALL
|
|
SELECT ASSOCIATEDNO AS BSNO,ASSOCIATEDNO MASTERNO, 'WMS' AS OPLB, '仓储业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME, WMSNO AS CUSTNO,WMSNO ORDERNO, BLNO MblNo,'' HBLNO, WMSDATE AS ETD,'' ETA
|
|
,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,(select top 1 showname from [user] where gid= createuser) AS INPUTBY,'' BLTYPE,
|
|
CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, '' AS CUSTOMNO,
|
|
case when isnull(WMSDATE,'')='' then '' else dbo.trimdate(WMSDATE) end ACCDATE ,
|
|
'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
'' CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,WMSDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,'' REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.WMS WITH (NOLOCK) where ASSOCIATEDNO=gid
|
|
UNION ALL
|
|
SELECT GID AS BSNO, GID MASTERNO,'WMS_IN' AS OPLB, '仓储入库' AS OPLBNAME,'仓储入库' AS BSTYPE, CUSTOMERNAME, WMSNO AS CUSTNO,WMSNO ORDERNO, BLNO MblNo,'' HBLNO, WMSDATE AS ETD,'' ETA
|
|
,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,WMSOP AS INPUTBY,'' BLTYPE,
|
|
CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=WMS.MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, CUSTOMNO, ACCDATE ,
|
|
'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME,
|
|
FEESTATUS,WMSDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.WMS WITH (NOLOCK) where ASSOCIATEDNO<>gid
|
|
UNION ALL
|
|
SELECT GID AS BSNO,GID MASTERNO, 'WMS_OUT' AS OPLB, '仓储出库' AS OPLBNAME,'仓储出库' AS BSTYPE, CUSTOMERNAME, BSNO AS CUSTNO,BSNO as ORDERNO, ISNULL(
|
|
(select top 1 BLNO from wms where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)),
|
|
(select top 1 BLNO from wms where gid = (select top 1 ASSOCIATEDNO from wms_in where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)))) MblNo,'' HBLNO, DODATE AS ETD,'' ETA
|
|
,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,WMSOP AS INPUTBY,'' BLTYPE,
|
|
CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=wms_out.MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, CUSTOMNO, ACCDATE ,
|
|
'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME,
|
|
FEESTATUS,DODATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.wms_out WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT b.BSNO,b.BSNO MASTERNO, 'op_airn' AS OPLB, '国内空运' AS OPLBNAME,'国内空运' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA
|
|
,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE , OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, '' AS CUSTOMNO,
|
|
ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE, FORWARDER
|
|
,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) AS NETWEIGHT
|
|
,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE
|
|
,c.CARGONAME GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' AS CUSTOMDATE,'' ENTERP
|
|
,(case b.BLTYPE when '国内分单' then c.BOXCOUNT else d.BOXCOUNT end) PKGS
|
|
,(case b.BLTYPE when '国内分单' then c.CBM else d.CBM end) CBM
|
|
,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO,
|
|
INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE
|
|
,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_airn b WITH (NOLOCK)
|
|
left join OP_AIRN_CARGO C on b.BLTYPE='国内分单' and c.bsno = B.bsno
|
|
left join OP_AIRN_CARGO D on b.BLTYPE='国内主单' and c.bsno =(select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单')
|
|
UNION ALL
|
|
SELECT BSNO, BSNO MASTERNO,'op_truck_bulk' AS OPLB, CASE WHEN TRANSTYPE='普运' THEN '陆运普货订单' ELSE '陆运集运订单' END AS OPLBNAME,CASE WHEN TRANSTYPE='普运' THEN '陆运普货订单' ELSE '陆运集运订单' END as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,ORDERNO MBLNO,ORDERNO HBLNO, ETD,ETA
|
|
,STLDATE,STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE,
|
|
CREATETIME, BSSTATUS, SALE, OP, DDOP AS DOC,CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_truck_bulk WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,BSNO MASTERNO, 'op_truck_bulk_pc' AS OPLB, CASE WHEN TRANSTYPE='普运' THEN '陆运普货派车' ELSE '陆运集运派车' END AS OPLBNAME,CASE WHEN TRANSTYPE='普运' THEN '陆运普货派车' ELSE '陆运集运派车' END as BSTYPE,CUSTOMERNAME, CUSTNO,'' ORDERNO,'' MBLNO,'' HBLNO, ETD,ETA
|
|
,STLDATE,STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE,
|
|
CREATETIME, BSSTATUS,'' SALE, OP, DDOP AS DOC,'' CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_truck_bulk_pc WITH (NOLOCK)
|
|
UNION ALL
|
|
SELECT BSNO,BSNO MASTERNO, 'op_ctnmng' AS OPLB, '集装箱管理' AS OPLBNAME,BLTYPE as BSTYPE,CUSTOMERNAME,CUSTNO,'' ORDERNO, MBLNO,'' HBLNO,BSDATE ETD,ETD ETA
|
|
,'' STLDATE,'' STLNAME, VESSEL, VOYNO,OP AS INPUTBY,BLTYPE BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER,0 NETWEIGHT,0 KGS,TEU, CNTRTOTAL,
|
|
CORPID,CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,0 ISVOU,'' VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_ctnmng WITH (NOLOCK)
|
|
UNION ALL
|
|
|
|
SELECT BSNO,BSNO MASTERNO, 'op_InternalTrade' AS OPLB, '内贸海运管理' AS OPLBNAME,'整箱' as BSTYPE,CUSTOMERNAME,CUSTNO,'' ORDERNO, MBLNO,'' HBLNO,dbo.trimdate(ETD) ETD,dbo.trimdate(ETA) ETA
|
|
,dbo.trimdate( STLDATE) STLDATE,STLNAME, VESSEL, VOYNO,OP AS INPUTBY,'整箱' BLTYPE,
|
|
BSDATE AS CREATETIME, BSSTATUS,(select showname from [user] where GID=SALE ) SALE, OP, OP AS DOC, CUSTSERVICE, PORTLOADID+'_'+PORTLOAD PORTLOAD, PORTDISCHARGEID+'_'+PORTDISCHARGE PORTDISCHARGE,'' CUSTOMNO,
|
|
ACCDATE,CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER,0 NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT, SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO,
|
|
'' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS, OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,isnull(PORTLOADREMARK,'')+';;'+isnull(VIA_MARK,'') remark,'' TRADETERM,'' PLACERECEIPT,PlACERECEIPT DESTINATION,SEALNO CNTRSEALNO
|
|
,BillFeeStatus ,0 ISVOU,'' VOUNO,PORTDISCHARGE DESTINATIONID,CORPID SALECORPID,'' YARD,dbo.trimtime(DELIVERYDATE) DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.op_InternalTrade WITH (NOLOCK)
|
|
union all
|
|
SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_IN_DO' AS OPLB, '入库执行' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'入库执行' BLTYPE,
|
|
CreateDate CREATETIME, BSSTATUS,'' SALE ,(select SHOWNAME from vw_user where USERID=CreateID ) OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, KGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME,
|
|
FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP,PKGS,CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,KGS FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.VW_OP_WMS_IN_DO
|
|
union all
|
|
SELECT Convert(varchar(36),OP_WMS_OUT_DO_BSNO.GID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_OUT_DO' AS OPLB, '出库明细' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,WMSNO CUSTNO,WMSNO ORDERNO,OP_WMS_OUT_DO.MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,OP_WMS_OUT_DO.TRUCKNO VOYNO, Creator,'出库明细' BLTYPE,
|
|
CreateDate CREATETIME, BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) AS NETWEIGHT, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, isnull((select sum(PKGS) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0)PKGS, isnull((select sum(CBM) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_OUT_DO_BSNO left join dbo.OP_WMS_OUT_DO on OP_WMS_OUT_DO.WMSDOID=OP_WMS_OUT_DO_BSNO.BSNO
|
|
|
|
union all
|
|
SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_OUT_DO' AS OPLB, '出库作业' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,WMSNO CUSTNO,WMSNO ORDERNO,OP_WMS_OUT_DO.MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,TRUCKNO VOYNO, Creator,'出库作业' BLTYPE,
|
|
CreateDate CREATETIME, BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) AS NETWEIGHT, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, isnull((select sum(PKGS) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0)PKGS, isnull((select sum(CBM) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_OUT_DO
|
|
|
|
union all
|
|
SELECT Convert(varchar(36),D.WMSDUIDETAILID) BSNO,Convert(varchar(36),D.WMSDUIID) MASTERNO, 'OP_WMS_FEEDUI' AS OPLB, '仓储月结账单' AS OPLBNAME,'仓储业务' AS BSTYPE, D.CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,dbo.trimtime(D.STARTDATE) ETD,dbo.trimtime(D.ENDDATE) ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'仓储月结' BLTYPE,
|
|
CreateDate CREATETIME,0 BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),h.ACCDATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
FEESTATUS,D.ACCDATE AS OPDATE,D.ACCDATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,h.REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_FEEDUI_STORAGE_DETAIL D left join OP_WMS_FEEDUI_STORAGE h on D.WMSDUIID=h.WMSDUIID
|
|
|
|
union all
|
|
SELECT Convert(varchar(36),WMSWEIGHID) BSNO,Convert(varchar(36),WMSWEIGHID) MASTERNO, 'OP_WMS_WEIGH' AS OPLB, '过磅业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,DODATE ETD,DODATE ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'过磅业务' BLTYPE,
|
|
CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
'' FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_WEIGH
|
|
union all
|
|
SELECT Convert(varchar(36),WMSTRANSFERGOODSID) BSNO,Convert(varchar(36),WMSTRANSFERGOODSID) MASTERNO, 'OP_WMS_TRANSFERGOODS' AS OPLB, '货转业务' AS OPLBNAME,'仓储业务' AS BSTYPE, NEWCUSTOMERNAME CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,(select MBLNO from op_wms where wmsid=(select top 1 WMSID from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=OP_WMS_TRANSFERGOODS.WMSTRANSFERGOODSID))MBLNO,'' HBLNO,TRANSFERDATE ETD,TRANSFERDATE ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'货转业务' BLTYPE,
|
|
CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),TRANSFERDATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
'' FEESTATUS,TRANSFERDATE AS OPDATE,TRANSFERDATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_TRANSFERGOODS
|
|
union all
|
|
SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_MOVE' AS OPLB, '移库业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,(select MBLNO from OP_WMS where WMSID=OP_WMS_MOVE.WMSID) MBLNO,'' HBLNO,DODATE ETD,DODATE ETA
|
|
,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'移库业务' BLTYPE,
|
|
CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO,
|
|
CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL,
|
|
CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME,
|
|
'' FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO,
|
|
''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL
|
|
,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS
|
|
FROM dbo.OP_WMS_MOVE
|
|
GO
|
|
|