1
This commit is contained in:
89
aoyuPlugIn/汇威/SQL Server/hw_get_zpjjmxb.sql
Normal file
89
aoyuPlugIn/汇威/SQL Server/hw_get_zpjjmxb.sql
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[hw_get_zpjjmxb] Script Date: 2025/9/26 15:54:09 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
ALTER PROCEDURE [dbo].[hw_get_zpjjmxb]
|
||||
@fdate1 NVARCHAR(20)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
DECLARE @fdate NVARCHAR(20)
|
||||
SET @fdate=''''+ @fdate1 + ''''
|
||||
|
||||
DELETE hw_zpjjmxb where jjdate=@fdate1
|
||||
|
||||
|
||||
--1<EFBFBD><EFBFBD>ȡ<EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD>ǰת<EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
declare @bzrs nvarchar(max)
|
||||
set @bzrs='(select p1.FID,p1.rs-isnull(p2.syqrs,0) as rs from (select t1.FID, count(*) as rs
|
||||
from GAT_DAY_ZP t1 join GAT_DAY_jt_ZP jt on t1.fid=jt.fid
|
||||
where F_DATE='+@fdate+' group by t1.FID) p1 left outer join
|
||||
( select t1.FID, count(*) as syqrs from GAT_DAY_ZP t1 join GAT_DAY_jt_ZP t2 on t1.fid=t2.fid
|
||||
join GAT_YGCQs t3 on t2.f_ygno=t3.f_ygnm join GAT_YGCQ t4 on t3.fid=t4.fid and t4.f_date='+@fdate+'
|
||||
left outer join hw_xygzjj t5 on t3.F_YGNM=t5.F_YGID and t4.F_DATE>=t5.F_DATE
|
||||
where t5.F_YGID is null and t3.f_issyq=''<EFBFBD><EFBFBD>'' and t1.F_DATE='+@fdate+' group by t1.FID) p2 on p1.fid=p2.FID)'
|
||||
|
||||
--select @bzrs
|
||||
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD>(jjDate, ygNo, ygNm, zlNo, cpNm, price, fqty, jtrs, je, bz, zje,jjcsbt,gwbt,jjdh)
|
||||
declare @sql nvarchar(max)
|
||||
set @sql='insert into hw_zpjjmxb
|
||||
select t1.F_DATE,
|
||||
yg.FNUMBER,
|
||||
ygs.FNAME,
|
||||
scdd.FNUMBER,
|
||||
scdd.FCPNM,
|
||||
t2.F_PRICE,
|
||||
case when isnull(rs1.rs,0)=0 then 0 else t2.F_FQTY end,
|
||||
rs1.rs,
|
||||
case when isnull(rs1.rs,0)=0 then 0 else t2.F_FQTY/rs1.rs end * t2.F_PRICE,
|
||||
0,
|
||||
case when isnull(rs1.rs,0)=0 then 0 else t2.F_FQTY/rs1.rs end * t2.F_PRICE,0,0,t1.fbillno
|
||||
|
||||
from GAT_DAY_ZP t1 join GAT_DAY_CP_ZP t2 on t1.FID=t2.FID
|
||||
join hw_scdd_select scdd on t2.F_SCNO=scdd.FID
|
||||
join GAT_DAY_JT_ZP t3 on t1.FID=t3.FID
|
||||
join T_HR_EMPINFO yg on t3.F_YGNO=yg.FID
|
||||
join T_HR_EMPINFO_L ygs on yg.FID=ygs.FID
|
||||
join '+@bzrs+' rs1 on t1.fid=rs1.fid
|
||||
where t1.F_DATE='+@fdate
|
||||
|
||||
|
||||
--select @sql
|
||||
exec(@sql)
|
||||
|
||||
|
||||
--<EFBFBD><EFBFBD><EFBFBD>˼Ƽ<EFBFBD>
|
||||
insert into hw_zpjjmxb select t1.F_DATE as <EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,yg.FNUMBER as Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ygs.FNAME as Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, scdd.FNUMBER as <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, scdd.FCPNM as <EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t2.F_PRICE,t2.F_FQTY
|
||||
,null as <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t2.F_JJGZ as <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,null as <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t2.F_JJGZ as <EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>,0,0,t1.fbillno
|
||||
from GAT_DAY_ZP t1 join GAT_DAY_GR_ZP t2 on t1.FID=t2.FID
|
||||
|
||||
join hw_scdd_select scdd on t2.F_SCNO=scdd.FID
|
||||
|
||||
join T_HR_EMPINFO yg on t2.F_YGNO=yg.FID
|
||||
join T_HR_EMPINFO_L ygs on yg.FID=ygs.FID
|
||||
where t1.F_DATE=@fdate1
|
||||
-----------------------------------------------
|
||||
update t1 set bz=t3.F_SYQBT,jjcsbt=t3.F_CSBT,gwbt=t3.F_GWBT from hw_zpjjmxb t1 join GAT_rgz t2 on t1.jjDate=t2.FDATE join GAT_rgzs t3 on t2.fid=t3.fid
|
||||
|
||||
join T_HR_EMPINFO yg on t3.F_YGNO=yg.FID
|
||||
and t1.ygno=yg.FNUMBER where t1.jjDate=@fdate1
|
||||
|
||||
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
update hw_zpjjmxb set bz=0 where bz>0 and jjDate=@fdate1 and FInterID not in (select min(FInterID) from hw_zpjjmxb where jjDate=@fdate1 group by ygno,bz)
|
||||
update hw_zpjjmxb set jjcsbt=0 where jjcsbt>0 and jjDate=@fdate1 and FInterID not in (select min(FInterID) from hw_zpjjmxb where jjDate=@fdate1 group by ygno,jjcsbt)
|
||||
update hw_zpjjmxb set gwbt=0 where gwbt>0 and jjDate=@fdate1 and FInterID not in (select min(FInterID) from hw_zpjjmxb where jjDate=@fdate1 group by ygno,gwbt)
|
||||
|
||||
|
||||
--<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>
|
||||
update hw_zpjjmxb set je=round(price*fqty/case when isnull(jtrs,0)=0 then 1 else jtrs end,2) ,
|
||||
zje=round( price*fqty/case when isnull(jtrs,0)=0 then 1 else jtrs end,2)+bz+jjcsbt+gwbt where jjdate=@fdate1
|
||||
|
||||
--
|
||||
DELETE t1 from hw_zpjjmxb t1 join T_HR_EMPINFO yg on t1.ygno=yg.FNUMBER
|
||||
|
||||
join GAT_YGCQs cqs on yg.FID=cqs.F_YGNM join GAT_YGCQ cq on cqs.fid=cq.fid
|
||||
where jjDate=@fdate1 and cq.F_DATE=@fdate1 and cqs.F_ISSYQ='<EFBFBD><EFBFBD>' and cqs.F_YGNM not in (select f_ygID from hw_xygzjj where f_date<=@fdate1)
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user