`
lancijk
  • 浏览: 388526 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

自动发牌(比较茂名)

阅读更多

1:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER  procedure [dbo].[PR_XZFW_ZiDongFaPai] --自动发预警和红黄牌
     @alarmyujing int, --预警提前天数
	 @alarmyellow int, --超期多少天发黄牌
	 @alarmred int --超期多少天发红牌
as
  declare @isweekday int --是否是工作日,1-工作日,0-休息日
  declare @nextIsweekday int --下一天是否是休息日 1-工作日,0-休息日
  declare @nextholidays int --接下来的几天是休息日的
  create table #tmp_fapaiList (
          YXTYWLSH varchar(100), --原业务流水号
          hzbh varchar(100), --回执编号
          HJDM varchar(10), --环节代码 
          SLSJ datetime,   --受理时间
          YBJSJ datetime,   --应办结时间
          GDBLSX int, --规定办理时限
          GDBLSXDW char(1), --规定办理时限单位
          SQDWHSQRXM varchar(100), --申请单位或申请人名称
          SLJGZZJGDM varchar(20), --受理机关组织机构代码
          SLJGMC varchar(50) --受理机关名称
  )
  declare @YXTYWLSH varchar(100)
  declare @hzbh varchar(100)
  declare @HJDM varchar(10)
  declare @SLSJ datetime
  declare @YBJSJ datetime
  declare @GDBLSX int
  declare @GDBLSXDW char(1)
  declare @SQDWHSQRXM varchar(100)
  declare @SLJGZZJGDM varchar(20)
  declare @SLJGMC varchar(50)  
  declare @primarykey varchar(20) 
  declare lsh_cur cursor for select * from #tmp_fapaiList

begin 
  --计算是否为节假日
  set @isweekday = 1
  set @nextholidays = 0
  if ((datepart(dw,getdate())=7) or (datepart(dw,getdate())=1)) --周六、周日
     set @isweekday = (select case when count(1)>0 then 1 else 0 end from Sys_Holiday where workflag='W' and datediff(dy,getdate(),today)=0)
  else
     set @isweekday = (select case when count(1)>0 then 0 else 1 end from Sys_Holiday where workflag='H' and datediff(dy,getdate(),today)=0)
  if( @isweekday = 1) --如果是工作日,则发牌,并判断明天是否是休息日,是则发明天的牌,以此类推
  begin
    set @nextIsweekday = 0
    while(@nextIsweekday=0)
    begin
       set @nextholidays = @nextholidays + 1
       if ((datepart(dw,getdate()+@nextholidays)=7) or (datepart(dw,getdate()+@nextholidays)=1)) --周六、周日
          set @nextIsweekday = (select case when count(1)>0 then 1 else 0 end from Sys_Holiday where workflag='W' and datediff(dy,getdate()+@nextholidays,today)=0)
       else
          set @nextIsweekday = (select case when count(1)>0 then 0 else 1 end from Sys_Holiday where workflag='H' and datediff(dy,getdate()+@nextholidays,today)=0)
     end
     set @nextholidays = @nextholidays - 1
     --发预警      
     delete from #tmp_fapaiList
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_YuJing where ZWJC_YuJing.YXTYWLSH=ZW_ShouLi.YXTYWLSH and YJLX='1')
        and convert(varchar(10), getdate()+@nextholidays, 120) >=  convert(varchar(10), YBJSJ-@alarmyujing, 120)
        and convert(varchar(10), getdate(), 120) <  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmyellow,'G'), 120)    
    
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))

     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_YuJing(OID, YXTYWLSH, HZBH, YJHJDM, YJYJ, YJSJ,
               YJLX, SLSJ, YBSJ, GDBLSX,  GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM,'即将超时', getdate(),
               '1', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     --deallocate lsh_cur
     --发黄牌   
     delete from #tmp_fapaiList 
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_RedYellow where ZWJC_RedYellow.YXTYWLSH=ZW_ShouLi.YXTYWLSH and FPLX='1' and PLX='1')
        and convert(varchar(10), getdate(), 120) >=  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmyellow,'G'), 120)
        and convert(varchar(10), getdate(), 120) <  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmred,'G'), 120)
  
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))
   
     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_RedYellow(OID, YXTYWLSH, HZBH, FPHJDM, FPSJ,FPLX,PLX,
                FPYY, SLSJ, YBSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM, getdate(),'1','1',
                '超时' + cast(@alarmyellow as varchar(5)) + '天未办结', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     --deallocate lsh_cur
     --发红牌   
     delete from #tmp_fapaiList 
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_RedYellow where ZWJC_RedYellow.YXTYWLSH=ZW_ShouLi.YXTYWLSH and FPLX='1' and PLX='2')
        and convert(varchar(10), getdate(), 120) >=  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmred,'G'), 120)

    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))

     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_RedYellow(OID, YXTYWLSH, HZBH, FPHJDM, FPSJ,FPLX,PLX,
                FPYY, SLSJ, YBSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM, getdate(),'1','2',
                '超时' + cast(@alarmred as varchar(5)) + '天未办结', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         delete from ZWJC_RedYellow where YXTYWLSH=@YXTYWLSH and FPLX='1' and PLX='1' 
   fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     deallocate lsh_cur
   end
end



 

 

2:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER  procedure [dbo].[PR_XZFW_ZiDongFaPai] --自动发预警和红黄牌
     @alarmyujing int, --预警提前天数
	 @alarmyellow int, --超期多少天发黄牌
	 @alarmred int --超期多少天发红牌
as
  declare @isweekday int --是否是工作日,1-工作日,0-休息日
  declare @nextIsweekday int --下一天是否是休息日 1-工作日,0-休息日
  declare @nextholidays int --接下来的几天是休息日的
  create table #tmp_fapaiList (
          YXTYWLSH varchar(100), --原业务流水号
          hzbh varchar(100), --回执编号
          HJDM varchar(10), --环节代码 
          SLSJ datetime,   --受理时间
          YBJSJ datetime,   --应办结时间
          GDBLSX int, --规定办理时限
          GDBLSXDW char(1), --规定办理时限单位
          SQDWHSQRXM varchar(100), --申请单位或申请人名称
          SLJGZZJGDM varchar(20), --受理机关组织机构代码
          SLJGMC varchar(50) --受理机关名称
  )
  declare @YXTYWLSH varchar(100)
  declare @hzbh varchar(100)
  declare @HJDM varchar(10)
  declare @SLSJ datetime
  declare @YBJSJ datetime
  declare @GDBLSX int
  declare @GDBLSXDW char(1)
  declare @SQDWHSQRXM varchar(100)
  declare @SLJGZZJGDM varchar(20)
  declare @SLJGMC varchar(50)  
  declare @primarykey varchar(20) 
  declare lsh_cur cursor for select * from #tmp_fapaiList

begin 
  --计算是否为节假日
  set @isweekday = 1
  set @nextholidays = 0
  if ((datepart(dw,getdate())=7) or (datepart(dw,getdate())=1)) --周六、周日
     set @isweekday = (select case when count(1)>0 then 1 else 0 end from Sys_Holiday where workflag='W' and datediff(dy,getdate(),today)=0)
  else
     set @isweekday = (select case when count(1)>0 then 0 else 1 end from Sys_Holiday where workflag='H' and datediff(dy,getdate(),today)=0)
  if( @isweekday = 1) --如果是工作日,则发牌,并判断明天是否是休息日,是则发明天的牌,以此类推
  begin
    set @nextIsweekday = 0
    while(@nextIsweekday=0)
    begin
       set @nextholidays = @nextholidays + 1
       if ((datepart(dw,getdate()+@nextholidays)=7) or (datepart(dw,getdate()+@nextholidays)=1)) --周六、周日
          set @nextIsweekday = (select case when count(1)>0 then 1 else 0 end from Sys_Holiday where workflag='W' and datediff(dy,getdate()+@nextholidays,today)=0)
       else
          set @nextIsweekday = (select case when count(1)>0 then 0 else 1 end from Sys_Holiday where workflag='H' and datediff(dy,getdate()+@nextholidays,today)=0)
     end
     set @nextholidays = @nextholidays - 1
     --发预警      
     delete from #tmp_fapaiList
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_YuJing where ZWJC_YuJing.YXTYWLSH=ZW_ShouLi.YXTYWLSH and YJLX='1')
        and convert(varchar(10), getdate()+@nextholidays, 120) >=  convert(varchar(10), YBJSJ-@alarmyujing, 120)
        and convert(varchar(10), getdate(), 120) <  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmyellow,'G'), 120)    
    
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))

     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_YuJing(OID, YXTYWLSH, HZBH, YJHJDM, YJYJ, YJSJ,
               YJLX, SLSJ, YBSJ, GDBLSX,  GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM,'即将超时', getdate(),
               '1', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     --deallocate lsh_cur
     --发黄牌   
     delete from #tmp_fapaiList 
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_RedYellow where ZWJC_RedYellow.YXTYWLSH=ZW_ShouLi.YXTYWLSH and FPLX='1' and PLX='1')
        and convert(varchar(10), getdate(), 120) >=  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmyellow,'G'), 120)
        and convert(varchar(10), getdate(), 120) <  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmred,'G'), 120)
  
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))
   
     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_RedYellow(OID, YXTYWLSH, HZBH, FPHJDM, FPSJ,FPLX,PLX,
                FPYY, SLSJ, YBSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM, getdate(),'1','1',
                '超时' + cast(@alarmyellow as varchar(5)) + '天未办结', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     --deallocate lsh_cur
     --发红牌   
     delete from #tmp_fapaiList 
     insert into #tmp_fapaiList(YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC)
     select YXTYWLSH, hzbh, SLSJ, YBJSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC from ZW_ShouLi
     where not exists (select 1 from ZW_BanJie where ZW_BanJie.YXTYWLSH=ZW_ShouLi.YXTYWLSH)
        and not exists (select 1 from ZWJC_RedYellow where ZWJC_RedYellow.YXTYWLSH=ZW_ShouLi.YXTYWLSH and FPLX='1' and PLX='2')
        and convert(varchar(10), getdate(), 120) >=  convert(varchar(10), dbo.getWorkDayADDWithType(YBJSJ,@alarmred,'G'), 120)

    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct yxtywlsh from dbo.ZW_TeBieChengXuShenQing a where not exists (select 1 from dbo.ZW_TeBieChengXuJieGuo b where a.yxtywlsh=b.yxtywlsh and a.tbcxyxtywlsh=b.tbcxyxtywlsh))
    delete from  #tmp_fapaiList where YXTYWLSH in (select distinct a.yxtywlsh from dbo.ZW_BuJiaoGaoZhi a where not exists (select 1 from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH) or a.bjgzsj>(select isnull(max(bjsj), '2000-01-01') from dbo.ZW_BuJiaoShouLi b where a.YXTYWLSH=b.YXTYWLSH))

     update #tmp_fapaiList set HJDM = '0005'
     update #tmp_fapaiList set HJDM = (select max(b.STEPCODE) from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
        where exists (select 1 from zw_workflow_StepStatus a,zw_workflow_stepdesc b where a.YXTYWLSH=#tmp_fapaiList.YXTYWLSH 
               and a.BLSTATUS='0' and a.WORKFLOWID=b.WORKFLOWID and a.STEPDESCID=b.STEPDESCID)
     open lsh_cur
     fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     while @@fetch_status=0
     begin
         exec PR_XZFW_getPrimaryKey @primarykey output
         insert into ZWJC_RedYellow(OID, YXTYWLSH, HZBH, FPHJDM, FPSJ,FPLX,PLX,
                FPYY, SLSJ, YBSJ, GDBLSX, GDBLSXDW, SQDWHSQRXM, SLJGZZJGDM, SLJGMC, BZ) 
         values (@primarykey, @YXTYWLSH, @hzbh, @HJDM, getdate(),'1','2',
                '超时' + cast(@alarmred as varchar(5)) + '天未办结', @SLSJ, @YBJSJ, @GDBLSX, @GDBLSXDW, @SQDWHSQRXM, @SLJGZZJGDM, @SLJGMC, '')
         delete from ZWJC_RedYellow where YXTYWLSH=@YXTYWLSH and FPLX='1' and PLX='1' 
   fetch next from lsh_cur into @YXTYWLSH,@hzbh,@HJDM,@SLSJ,@YBJSJ,@GDBLSX,@GDBLSXDW,@SQDWHSQRXM,@SLJGZZJGDM,@SLJGMC
     end
     close lsh_cur
     deallocate lsh_cur
   end
end



 

分享到:
评论

相关推荐

    全自动发牌机的设计说明书

    针对以上问题,本课题将虚拟产品开发技术与现实样机技术结合,设计并制作出一款结构简单、运行可靠、造价低廉的 自动洗牌发牌机样机,并对自动洗牌发牌机样机进行了深入研究。对洗牌发牌机的功能及特点进行研究,...

    C语言自动发牌系统

    《C语言实现自动发牌系统详解》 C语言是一种经典的编程语言,因其高效、简洁而深受程序员喜爱。在本项目中,我们探讨的是一个用C语言编写的自动发牌系统,特别针对四人桥牌游戏。四人桥牌是桥牌的一种形式,需要四...

    自动发牌游戏

    在自动发牌游戏中,开发一个基于C语言的自动洗牌和发牌系统是学习编程和算法设计的一个有趣实践。这个项目涉及到随机数生成、数组操作以及基本的文件操作。下面我们将详细探讨这些知识点。 首先,**随机数生成**是...

    自动发牌问题.zip

    在本项目中,我们面临的是一个自动发牌问题,旨在使用C++编程语言实现一个算法,将一副标准的52张扑克牌随机分配给四位玩家,并检测每家手牌中是否存在特定的组合,如三带二、顺子、同花顺、五张同色牌(也称为铁支...

    一个自动发牌算法(写的不错)

    3. **牌的分配**:发牌算法需要将牌依次分配给每个玩家,直到牌发完为止。这可以通过循环遍历玩家列表并逐个发牌的方式实现。 4. **公平性**:确保每个玩家得到相同数量的牌,尤其在多人游戏中,这至关重要。例如,...

    自动洗牌发牌试验源码(c语言版)

    发牌开始后,随机从未发牌堆中抽取一张,并发给第一个个人,然后抽取第二张,发给第二个人,重复这个流程直到52张牌发完为止。玩牌的人数为固定4人。 发牌完毕后,请将每个人拿到的牌按照红桃、黑桃、方块和梅花...

    C语言实现自动发牌程序

    C语言实现自动发牌程序 C语言实现自动发牌程序是指使用C语言编写一个自动发牌程序,该程序可以将52张牌随机分配给4名玩家。该程序主要涉及到数组、随机数生成、循环语句等C语言基本概念。 C语言自动发牌程序的主要...

    jQuery发牌效果

    jQuery发牌效果是一种在网页上实现模拟扑克牌发牌动画的技术,它通常用于增强网站的交互性和趣味性,尤其适用于游戏、教学或者演示类的网页应用。jQuery库因其简洁的API和强大的DOM操作能力,成为了实现此类效果的...

    java发牌程序,扑克牌

    Java发牌程序是一种基于Java编程语言开发的应用,用于模拟扑克牌游戏中的发牌过程。...通过学习和实践这些概念,开发者不仅可以构建出一个功能完善的扑克牌发牌程序,还能深入理解Java编程的各个方面。

    洗牌发牌模拟系统课程设计报告--C语言

    【洗牌发牌模拟系统】是一个使用C语言实现的课程设计项目,旨在加深对C语言编程、结构化设计思想和小型系统开发的理解。系统的主要功能包括构建扑克牌、洗牌和发牌,同时具备图形化的结果显示。以下是这个系统的关键...

    c++ 发牌程序 数据

    在C++编程中,设计一个发牌程序是一个有趣且实用的练习,它可以加深对随机数生成、数组管理和算法设计的理解。下面将详细讲解这个“c++ 发牌程序”相关的知识点。 1. **随机数生成**:在C++中,生成随机数是通过`...

    vb60编写的桥牌随机发牌程序,每一副牌有牌号、局况和发牌者。

    在桥牌游戏中,牌局的公平性至关重要,而随机发牌是确保公平性的基础。VB60(Visual Basic 6.0)是一种经典的编程语言,可以用于编写各种应用,包括桥牌随机发牌程序。下面我们将深入探讨这个程序的实现原理以及与之...

    java斗地主发牌程序

    【Java斗地主发牌程序】是一个典型的基于Java编程语言实现的桌面游戏应用,它主要用于模拟斗地主游戏中的发牌过程。在这个程序中,我们可以深入学习到Java的基础语法、面向对象编程思想以及随机数生成等核心概念。...

    随机发牌 C语言 随机发牌 C语言 随机发牌 C语言

    这样可以方便地对牌进行操作,如洗牌和发牌。 3. **随机函数**:在C语言中,`&lt;stdlib.h&gt;`库提供了`rand()`函数来生成随机数,配合`srand()`函数设置随机数种子,可以实现随机发牌。通常,我们将当前时间作为种子,...

    VB6.0编写的桥牌发牌程序

    桥牌是一种广受欢迎的四人扑克游戏,而发牌程序是桥牌游戏中不可或缺的一部分。VB6.0(Visual Basic 6.0)是一款由微软公司开发的可视化的编程环境,它允许开发者创建Windows应用程序,包括游戏。在这个"VB6.0编写的...

    纸牌的洗牌与发牌过程C版

    ### 纸牌游戏中的洗牌与发牌过程——基于C语言实现 #### 概述 本篇文章将详细介绍一个基于C语言实现的纸牌洗牌与发牌过程的程序。该程序通过一系列算法实现了随机洗牌及按照规定规则进行发牌的功能,并能够直观地...

    图形版发牌游戏--扑克牌图片

    在这个名为“图形版发牌游戏--扑克牌图片”的项目中,我们可以看到重点在于利用Python编程语言来创建一个具有图形界面的扑克牌游戏。这涉及到多个IT领域的知识点,包括Python编程、图形用户界面(GUI)设计、图像...

    发牌问题 随机数 发牌问题

    一副牌出去大小王52张,随机发牌,四人每次都得到不同的牌

Global site tag (gtag.js) - Google Analytics