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.

113 lines
3.8 KiB
Transact-SQL

-- 正本pdf 与邮件中的征文进行比较,看pdf 文件是否缺失
select * from t_op_seae s where s. in (
select tdh--, 邮件发送日期
from
(
select
ltrim(
rtrim(SUBSTRING(
substring( ,charindex('number',v.,1)+6,LEN(v.)-charindex('number',v.,1)),1
,LEN(substring( ,charindex('number',v.,1)+6,LEN(v.)-charindex('number',v.,1)))-
LEN(' is now available'))
)
) as tdh, ,
from
(select m.id,m.,m.,m.,DATEDIFF(mi,m.,m.)as minYsh
from t_op_seae_edi_mail m where like '%origin%'and >=cast(GETDATE()-3 as DATE)and <cast(GETDATE()+1 as DATE)
)v
)
vv
where tdh not in
(
select t. -- , t.任务类型
from t_op_task t where t.>=cast(GETDATE()-3 as DATE)and < DATEADD(MI,-10,GETDATE())
and t.='ORIGINAL'
)
)
----------------
---清理临时表
---------必须是两个..
if object_id('tempdb..#tempWarnlist') is not null Begin
drop table #tempWarnlist
END
---创建临时表
CREATE TABLE [dbo].#tempWarnlist(
[ID] [int] IDENTITY(1,1) NOT NULL,
[MblNo] [varchar](20) NOT NULL,
[WarnDate] [datetime] NOT NULL,
[WarnType] [varchar](20) NOT NULL,
[createdate] [datetime] NOT NULL default getdate()
)
---将相关数据插入到临时表:查找邮件里有但是任务里确找不到正本的记录
insert into #tempWarnlist (mblno,warndate,warntype)
select tdh, ,'预警提醒'
from
(
select
ltrim(
rtrim(SUBSTRING(
substring( ,charindex('number',v.,1)+6,LEN(v.)-charindex('number',v.,1)),1
,LEN(substring( ,charindex('number',v.,1)+6,LEN(v.)-charindex('number',v.,1)))-
LEN(' is now available'))
)
) as tdh, cast( as DATETIME) as ,
from
(select m.id,m.,m.,m.,DATEDIFF(mi,m.,m.)as minYsh
from t_op_seae_edi_mail m where like '%origin%'and >=cast(GETDATE()-7 as DATE)and <cast(GETDATE()+1 as DATE)
)v
)
vv
where tdh not in
(
select t. -- , t.任务类型
from t_op_task t where t.>=cast(GETDATE()-7 as DATE)and < DATEADD(MI,-10,GETDATE())
and t.< DATEADD(MI,-50,GETDATE())
and t.='ORIGINAL' and t.='FTP'
)
and not exists ( select Mblno from t_op_seae_task_warn_mblno w where w.MblNo= vv.tdh and w.Warndate=vv.)
---将临时表的数据插入到预警任务列表
--- delete from t_op_seae_task_warn_mblno
--- select * from t_op_seae_task_warn_mblno
----------------
insert into t_op_seae_task_warn_mblno (mblno,warndate,warntype)
select [MblNo], [WarnDate] , [WarnType]
from #tempWarnlist
----形成任务(注意这里有问题)
insert into t_op_task
([任务编号] , [任务类型],[任务来源],[任务状态],[任务说明]
,[发起人] ,[录入日期] ,[任务开始时间] ,[完成方式]
,[提单号],[文件编号],[邮件编号],[电子档案路径],[是否公共],[任务相关人员],[SEA编号])
select NEWID(),wn.WarnType ,'邮件分析','待确认','有Original Bill邮件无正本' ,
'DEMO-SA',GETDATE(),wn.WarnDate,'手动',
wn.MblNo,null,null,null,case when LEN(isnull(s.,''))<1 then 1 else 0 end ,s.,s.
from #tempWarnlist wn left join t_op_seae s on wn.MblNo= s. and s.='普通货'
------------------------------
--delete from t_op_seae_task_warn_mblno;
delete from t_op_task where ='预警提醒'
select * from t_op_task where ='预警提醒'
select * from t_op_seae s where s. in
(
select m.mblno from t_op_seae_task_warn_mblno m
)
select distinct s. from t_op_seae s
select cast(GETDATE() as DATE),DATEADD(MI,-10,GETDATE()),GETDATE();