|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * INTO TImpItemBaseComm
|
|
|
|
|
FROM TItemBaseComm
|
|
|
|
|
WHERE 1=0
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpItemBaseComm DROP COLUMN FPerfMode
|
|
|
|
|
ALTER TABLE TImpItemBaseComm DROP COLUMN FPerfValue
|
|
|
|
|
ALTER TABLE TImpItemBaseComm DROP COLUMN FCostMode
|
|
|
|
|
ALTER TABLE TImpItemBaseComm DROP COLUMN FCostValue
|
|
|
|
|
ALTER TABLE TImpItemBaseComm ADD FEmpId BIGINT
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IF object_id('dbo.PImportBKEmpItemBaseCommOne','P') IS NOT NULL
|
|
|
|
|
BEGIN
|
|
|
|
|
DROP PROCEDURE dbo.PImportBKEmpItemBaseCommOne
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE PROCEDURE PImportBKEmpItemBaseCommOne
|
|
|
|
|
(
|
|
|
|
|
@WorkType VARCHAR(20),
|
|
|
|
|
@DispatchMode VARCHAR(20),
|
|
|
|
|
@ModeField VARCHAR(20),
|
|
|
|
|
@ValueField VARCHAR(20),
|
|
|
|
|
@HasPayment BIT
|
|
|
|
|
)
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ҵ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE @Sql VARCHAR(8000)
|
|
|
|
|
|
|
|
|
|
SELECT @Sql = '
|
|
|
|
|
INSERT #Comm (FId,FEmpId,FCompId,FItemId,FPayTypeId,FWorkType,FDispatchMode,FCommMode,FCommValue,FCompNo,FItemNo,FPayTypeNo)
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
|
|
|
FEmpId AS FEmpId,
|
|
|
|
|
dbo.FNBKCompId(heb00c) AS FCompId,-- <EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD>
|
|
|
|
|
FItemId AS FItemId, --<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
0 AS FPayTypeId,
|
|
|
|
|
' + @WorkType + ' AS FWorkType,
|
|
|
|
|
' + @DispatchMode + ' AS FDispatchMode,
|
|
|
|
|
dbo.FNBKItemCommMode('+@ModeField+') AS FCommMode,
|
|
|
|
|
ISNULL(' + @ValueField + ',0) AS FCommValue,
|
|
|
|
|
|
|
|
|
|
heb00c AS FCompNo,
|
|
|
|
|
heb02c AS FItemNo, '
|
|
|
|
|
+ CASE WHEN @HasPayment = 1 THEN '
|
|
|
|
|
heb56c ' ELSE ' CAST(''*'' AS VARCHAR(20))' END + ' AS FPayTypeNo '
|
|
|
|
|
+' FROM {FDB}.hem02
|
|
|
|
|
WHERE LEN(heb00c) <= 5
|
|
|
|
|
AND FEmpId IS NOT NULL
|
|
|
|
|
AND cast(FItemId as bigint) != 0 '
|
|
|
|
|
print @SQL
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL @SQL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
IF object_id('dbo.PImportBKEmpItemBaseComm','P') IS NOT NULL
|
|
|
|
|
BEGIN
|
|
|
|
|
DROP PROCEDURE dbo.PImportBKEmpItemBaseComm
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
CREATE PROCEDURE PImportBKEmpItemBaseComm
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
--drop table #Comm
|
|
|
|
|
-- EXEC PExecImportSQL 'SELECT * FROM {FDB}.hem01 '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE #Comm
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT not null,
|
|
|
|
|
FCompId BIGINT not null,
|
|
|
|
|
FEmpId BIGINT not null,
|
|
|
|
|
FItemId BIGINT not null,
|
|
|
|
|
FPayTypeId BIGINT not null,
|
|
|
|
|
FWorkType BIGINT not null,
|
|
|
|
|
FDispatchMode BIGINT not null,
|
|
|
|
|
FCommMode INT not null,
|
|
|
|
|
FCommValue Decimal(18,6) not null,
|
|
|
|
|
FCompNo VARCHAR(5) NOT NULL,
|
|
|
|
|
FItemNo VARCHAR(20) NOT NULL,
|
|
|
|
|
FPayTypeNo VARCHAR(20) NOT NULL
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
-- DROP TABLE #Comm
|
|
|
|
|
|
|
|
|
|
SELECT * FROM #Comm
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL 'DELETE {FDB}.hem02 WHERE heb02c not in (select gda01c from {FDB}.gdm01)'
|
|
|
|
|
|
|
|
|
|
DECLARE @HasPayment BIT
|
|
|
|
|
DECLARE @Sql NVARCHAR(4000)
|
|
|
|
|
SELECT @Sql = N'SELECT @HasPayment = (SELECT TOP 1 1 FROM {FDB}.syscolumns WHERE name = ''heb56c'' AND id = (select id from {FDB}.sysobjects where name =''hem02'' and type = ''U''))'
|
|
|
|
|
|
|
|
|
|
EXEC PBKBuildSQL @Sql,@Sql OUTPUT
|
|
|
|
|
|
|
|
|
|
print @Sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exec sp_executesql @Sql--<EFBFBD><EFBFBD>ʾ@sql<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
,N'@HasPayment BIT out'
|
|
|
|
|
,@HasPayment out --<EFBFBD>͵<EFBFBD><EFBFBD>ô洢<EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><EFBFBD>,ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
|
|
|
|
SET @HasPayment = ISNULL(@HasPayment,0)
|
|
|
|
|
|
|
|
|
|
print @HasPayment
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11001,10001,'heb03i','heb04f', @HasPayment
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11001,10002,'heb09i ','heb10f',@HasPayment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>й<EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11002,10001,'heb05i','heb06f',@HasPayment
|
|
|
|
|
--<EFBFBD>й<EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11002,10002,'heb11i','heb12f',@HasPayment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--С<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11003,10001,'heb07i','heb08f',@HasPayment
|
|
|
|
|
--С<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11003,10002,'heb13i','heb14f',@HasPayment
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ĺ<EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11004,10001,'heb21i','heb22f' ,@HasPayment
|
|
|
|
|
--<EFBFBD>Ĺ<EFBFBD> <EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PImportBKEmpItemBaseCommOne 11004,10002,'heb23i','heb24f',@HasPayment
|
|
|
|
|
|
|
|
|
|
-- EXEC PExecImportSQL 'DELETE {TDB}.TItemBaseComm'
|
|
|
|
|
--EXEC PExecImportSQL 'SELECT * FROM #Comm'
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FPayTypeId = B.FId
|
|
|
|
|
FROM #Comm AS A,TPayAccount AS B
|
|
|
|
|
WHERE A.FPayTypeNo = B.FBKPayNo
|
|
|
|
|
AND A.FPayTypeNo != '*'
|
|
|
|
|
AND A.FPayTypeNo != ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE #Comm
|
|
|
|
|
WHERE FPayTypeNo != '*'
|
|
|
|
|
AND FPayTypeId = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
|
|
|
|
|
INSERT TImpItemBaseComm (FId,FEmpId,FCompId,FItemId,FPayTypeId,FWorkType,FDispatchMode,FCommMode,FCommValue)
|
|
|
|
|
SELECT FId,FEmpId,FCompId,FItemId,FPayTypeId,FWorkType,FDispatchMode,FCommMode,FCommValue
|
|
|
|
|
FROM #Comm AS A '
|
|
|
|
|
|
|
|
|
|
--select * from TItemBaseComm WHERE FCompId = 3472331387795668992
|
|
|
|
|
--select * from tcompany
|
|
|
|
|
drop table #Comm
|
|
|
|
|
|
|
|
|
|
UPDATE TItemCommSchemeMaster SET FAcum = 0
|
|
|
|
|
SELECT * FROM TItemCommSchemeMaster
|
|
|
|
|
INSERT TItemCommSchemeMaster(FId,FCompId,FName,FAcum)
|
|
|
|
|
SELECT A.FEmpId,A.FCompId,E.FName + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' ,1
|
|
|
|
|
FROM #Comm AS A,TEmployee AS E
|
|
|
|
|
WHERE A.FEmpId = E.FId
|
|
|
|
|
GROUP BY A.FEmpId,A.FCompId,E.FName + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TItemCommSchemeDetail
|
|
|
|
|
SELECT * FROM TItemCommSchemeDetail
|
|
|
|
|
|
|
|
|
|
INSERT TItemCommSchemeDetail(FId,FMasterId,FParentId,FItemId,FPayTypeId,FWorkType,FDispatchMode,FCommMOde,FCommValue,FCalcMode)
|
|
|
|
|
SELECT dbo.FNnewId(),FEmpId,0,FItemId,FPayTypeId,FWorkType,FDispatchMode,FCommMOde,FCommValue,0
|
|
|
|
|
FROM #Comm
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TemployeeCommScheme
|
|
|
|
|
|
|
|
|
|
DELETE TemployeeCommScheme
|
|
|
|
|
INSERT TemployeeCommScheme(FId,FEmpId,FCompId,FItemSchemeId,FGoodsSchemeId,FCardSaleSchemeId,FCourseSaleSchemeId)
|
|
|
|
|
SELECT dbo.FNnewId(),A.FId ,1,A.FId,0,0,0
|
|
|
|
|
FROM TEmployee AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TItemCommSchemeMaster WHERE FId = 9145434575807107128
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpItemBaseComm
|
|
|
|
|
|
|
|
|
|
DELETE TEmpPerfDetailDateCache#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END
|
|
|
|
|
GO
|