|
9#
楼主 |
发表于 2019-7-10 13:34:19
|
只看该作者
本帖最后由 李维强-15级 于 2019-7-20 14:23 编辑
BEGIN
DECLARE @CoordFee FLOAT,@TestFee FLOAT,@MeterialFee_WX FLOAT,@MeterialFee_KBS FLOAT,@MeterialFee_GP FLOAT,@MeterialFee_ZP FLOAT,@MeterialFee_YX FLOAT;
DECLARE @EquipFee_WX FLOAT,@EquipFee_KBS FLOAT,@EquipFee_GP FLOAT,@EquipFee_ZP FLOAT;
DECLARE @CivilPrice_WX FLOAT,@CivilPrice_HXN FLOAT;
DECLARE @InstallFee_KBS FLOAT,@InstallFee_GP FLOAT,@InstallFee_ZP FLOAT;
SET @CoordFee=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PECoordFee where PreEstId=1 AND PreEstType='用户工程');
SET @TestFee=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PETestFee where PreEstId=1 AND PreEstType='用户工程');
SET @MeterialFee_WX=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEMaterialFeeUser where TabType='WX' AND PreEstId=1 AND PreEstType='用户工程');
SET @MeterialFee_KBS=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEMaterialFeeUser where TabType='KBS' AND PreEstId=1 AND PreEstType='用户工程');
SET @MeterialFee_GP=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEMaterialFeeUser where TabType='GP' AND PreEstId=1 AND PreEstType='用户工程');
SET @MeterialFee_ZP=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEMaterialFeeUser where TabType='ZP' AND PreEstId=1 AND PreEstType='用户工程');
SET @MeterialFee_YX=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEMaterialFeeUser where TabType='YX' AND PreEstId=1 AND PreEstType='用户工程');
SET @EquipFee_WX=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEEquipFee where TabType='WX' AND PreEstId=1 AND PreEstType='用户工程');
SET @EquipFee_KBS=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEEquipFee where TabType='KBS' AND PreEstId=1 AND PreEstType='用户工程');
SET @EquipFee_GP=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEEquipFee where TabType='GP' AND PreEstId=1 AND PreEstType='用户工程');
SET @EquipFee_ZP=(SELECT SUM(QuoteMoney*Quantity) as num FROM o_PEEquipFee where TabType='ZP' AND PreEstId=1 AND PreEstType='用户工程');
SET @CivilPrice_WX=(SELECT SUM(UnitPrice*Quantity) AS num FROM o_PECivilPrice where TabType='WX' AND PreEstId=1 AND PreEstType='用户工程');
SET @CivilPrice_HXN=(SELECT SUM(UnitPrice*Quantity) AS num FROM o_PECivilPrice where TabType='HXN' AND PreEstId=1 AND PreEstType='用户工程');
SET @InstallFee_KBS=(SELECT SUM(QuoteMoney*Quantity) AS num FROM o_PEInstallFee WHERE TabType='KBS' AND PreEstId=1 AND PreEstType='用户工程');
SET @InstallFee_GP=(SELECT SUM(QuoteMoney*Quantity) AS num FROM o_PEInstallFee WHERE TabType='GP' AND PreEstId=1 AND PreEstType='用户工程');
SET @InstallFee_ZP=(SELECT SUM(QuoteMoney*Quantity) AS num FROM o_PEInstallFee WHERE TabType='ZP' AND PreEstId=1 AND PreEstType='用户工程');
SELECT @CoordFee as CoordFee,@TestFee as TestFee,@MeterialFee_WX as MeterialFee_WX;
END
复制用户版前期测算表
[SQL] syntaxhighlighter_viewsource syntaxhighlighter_copycode
BEGIN
DECLARE @tempid int,@tempEstId int;
SET @tempEstId=1;
insert INTO o_PreEstUser (Name,ProjectId,CreateTime,IsDelete,Type,XMMC,YDXZ,SSQY,JZMJ,RL,WXCD,HXNBJJE,
Memo_WXTJ,Memo_WXSB,Memo_WXCL,Memo_KBSSB,Memo_KBSCL,Memo_GYSB,Memo_GYCL,Memo_ZYSB,Memo_ZYCL,
Memo_ZTAZ,Memo_ZTTJSGF,Memo_ZTSYTSF,YZYQ_CF,Memo_YZYQCF,YZYQ_YHYB,Memo_YZYQYHYB,YZYQ_LLLJ,Memo_YZYQLLLJ,
YZYQ_CDZ,Memo_YZYQCDZ,DJHTJE,Memo_DJHTJE,SJF,Memo_SJF,JLF,Memo_JLF,DJGLF,Memo_DJGLF,SJ,Memo_SJ,ZJCB,Memo_ZJCB,
GSGLF,Memo_GSGLF,Memo_YWF,LRL,Memo_LRL)
SELECT '测试复制',ProjectId,CreateTime,IsDelete,Type,XMMC,YDXZ,SSQY,JZMJ,RL,WXCD,HXNBJJE,
Memo_WXTJ,Memo_WXSB,Memo_WXCL,Memo_KBSSB,Memo_KBSCL,Memo_GYSB,Memo_GYCL,Memo_ZYSB,Memo_ZYCL,
Memo_ZTAZ,Memo_ZTTJSGF,Memo_ZTSYTSF,YZYQ_CF,Memo_YZYQCF,YZYQ_YHYB,Memo_YZYQYHYB,YZYQ_LLLJ,Memo_YZYQLLLJ,
YZYQ_CDZ,Memo_YZYQCDZ,DJHTJE,Memo_DJHTJE,SJF,Memo_SJF,JLF,Memo_JLF,DJGLF,Memo_DJGLF,SJ,Memo_SJ,ZJCB,Memo_ZJCB,
GSGLF,Memo_GSGLF,Memo_YWF,LRL,Memo_LRL FROM o_PreEstUser where PreEstId=@tempEstId;
SET @tempid=(SELECT top 1 PreEstId from o_PreEstUser ORDER BY PreEstId DESC);
insert INTO o_PECoordFee (CooContent,CooDepart,money,Memo,IsDelete,PreEstId,PreEstType,Quantity,QuoteMoney)
SELECT CooContent,CooDepart,money,Memo,IsDelete,@tempid,PreEstType,Quantity,QuoteMoney
FROM o_PECoordFee where PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
INSERT INTO o_PETestFee (TestName,money,IsDelete,Memo,PreEstId,Quantity,QuoteMoney,PreEstType)
SELECT TestName,money,IsDelete,Memo,@tempid,Quantity,QuoteMoney,PreEstType
FROM o_PETestFee where PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
INSERT INTO o_PEMaterialFeeUser (EquipName,Specification,Unit,Type,LogTime,IsDelete,Price,Code,PreEstId,
EquipPriceId,TabType,PreEstType,Quantity,QuoteMoney,SumTax)
SELECT EquipName,Specification,Unit,Type,LogTime,IsDelete,Price,Code,@tempid,EquipPriceId,
TabType,PreEstType,Quantity,QuoteMoney,SumTax
FROM o_PEMaterialFeeUser where PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
INSERT INTO o_PEInstallFee (Name,Specification,Content,Unit,Money,Memo,IsDelete,PreEstId,Quantity,QuoteMoney,PreEstType,TabType)
SELECT Name,Specification,Content,Unit,Money,Memo,IsDelete,@tempid,Quantity,QuoteMoney,PreEstType,TabType
FROM o_PEInstallFee where PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
INSERT INTO o_PEEquipFee (EquipName,Specification,Unit,Type,LogTime,IsDelete,Price,Code,PreEstId,EquipPriceId,TabType,
PreEstType,Quantity,QuoteMoney,SumTax)
SELECT EquipName,Specification,Unit,Type,LogTime,IsDelete,Price,Code,@tempid,EquipPriceId,TabType,PreEstType,Quantity,
QuoteMoney,SumTax
FROM o_PEEquipFee where PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
DECLARE @tempCivilId int,@tempCivilAddId int;
DECLARE mycursor CURSOR FOR SELECT PECivilPriceId FROM o_PECivilPrice WHERE PreEstId=@tempEstId AND PreEstType='用户工程' and IsDelete<>1;
OPEN mycursor
FETCH NEXT FROM mycursor INTO @tempCivilId
WHILE (@@fetch_status = 0)
BEGIN
INSERT INTO o_PECivilPrice (Name,TaxRate,Unit,UnitPrice,Memo,IsDelete,LogTime,PreEstId,PreEstType,TabType,OrgCivilPriceId,Quantity)
SELECT Name,TaxRate,Unit,UnitPrice,Memo,IsDelete,LogTime,@tempid,PreEstType,TabType,OrgCivilPriceId,Quantity
FROM o_PECivilPrice where PECivilPriceId=@tempCivilId;
SET @tempCivilAddId=(SELECT top 1 PECivilPriceId FROM o_PECivilPrice ORDER BY PECivilPriceId DESC);
INSERT INTO o_PECivilPriceSingle (XMMC,GCLJSS,DW,GCL,RGDJ,CLDJ,PECivilPriceId,Memo)
SELECT XMMC,GCLJSS,DW,GCL,RGDJ,CLDJ,@tempCivilAddId,Memo FROM o_PECivilPriceSingle
WHERE PECivilPriceId=@tempCivilId;
FETCH NEXT FROM mycursor INTO @tempCivilId;
END
CLOSE mycursor
DEALLOCATE mycursor
END
|
|