1,在奥迪工装订购单表中开启导入Excel功能,把Excel表格中的数据导入后保存,审核后自动生成新的子订单合同
2,后台审核时触发生成子订单功能的存储过程
3,后台打开存储过程并且修改---》保存
USE [HYData]
GO
/****** Object: StoredProcedure [dbo].[SP_DDXXB_AODI] Script Date: 2023-08-18 9:23:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[SP_DDXXB_AODI] @DJLSH INT
AS
DECLARE @MDJLSH INT,@HJJE DEC(18,2),@HJSL DEC(18,2),@ZDR VARCHAR(20),@ZDRID VARCHAR(20)
DECLARE @JXSDM VARCHAR(60),@XH INT,@MXH INT
SELECT @JXSDM=JXSDM,@ZDR=ZDR,@ZDRID=ZDRID FROM ADGZDGDH WHERE DJLSH=@DJLSH
SELECT @MXH=MAX(XH)+1 FROM ADGZDGDB WHERE DJLSH=@DJLSH
SELECT @MDJLSH=MAX(DJLSH)+1 FROM DDXXBH
-----------------------------------------------------2023/08/18 修改增加字段CYLHTXKH,XKC插入时的默认值
insert into DDXXBH (DJLSH,DJBTZDH,DJFTZDH,DJSTZDH,JXSDM,KHMC,GSH,GSMC,SHDZ,LXFS,SFZP,FDDBR,NSRSBH,KHYX,KHZH,DH,YB,PP,CZ,WTDLR,BB,ZDRQ, HTH, DJH,YLHTH,ZDRID,ZDR,SHLXR,JEHJ,SLHJ,GL,CYLHTXKH,XKC)
SELECT @MDJLSH,0,0,0,JXSDM,KHMC,'10','宁波恒远制衣有限公司',SHDZ,LXFS,SFZP,FDDBR,NSRSBH,KHYX,KHZH,DH,YB,PP,CZ,WTDLR,'RMB',GETDATE(),'未生成','XSDDAD'+CAST(@MDJLSH AS varchar(6)) ,'1',@ZDRID,@ZDR,SHR,@HJJE,@HJSL,1,'N',0 FROM GSXXBH
where jxsdm=@JXSDM;
----------------------------------------------
select TOP 1 * into #t from DDXXBB
delete from #t
SET @XH=1
WHILE(@XH<=@MXH)
-----------------------------------------------------2023/08/18 修改插入临时表时4XL的复制数据
BEGIN
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','XS','件',ISNULL(XS,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','S','件',ISNULL(S,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','M','件',ISNULL(M,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','L','件',ISNULL(L,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','XL','件',ISNULL(XL,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','2XL','件',ISNULL(XXL,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','3XL','件',ISNULL(XXXL,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','4XL','件',ISNULL(XXXXL,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
INSERT INTO #t(djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT @MDJLSH,DJBTH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),WLDM,PZ,'无','QT','件',ISNULL(QT,0),DJ,'奥迪工服','',JE FROM ADGZDGDB WHERE DJLSH=@DJLSH AND XH=@XH
set @xh=@xh+1
END
INSERT INTO DDXXBB (djlsh,DJBTH,XH,kh,ks,YS,cm,DW,sl,dj,cpfl,cplx,JE)
SELECT DJLSH,ROW_NUMBER () OVER (ORDER BY (SELECT 1)),ROW_NUMBER () OVER (ORDER BY (SELECT 1)),kh,ks,YS,cm,DW,sl,dj,cpfl,
'奥迪工服',JE FROM #T WHERE SL>0
DROP TABLE #t
update ADGZDGDH SET DDDJH='XSDDAD'+CAST(@MDJLSH AS varchar(6)) WHERE DJLSH=@DJLSH
GO
4奥迪工装审核后,去查看子订单,发现已经生成
5,修改正确的预录合同号,和经销商,保存后会自动生成附体内容