|
|
|
|
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF object_id('dbo.PGetBizConfig','P') IS NOT NULL
|
|
|
|
|
BEGIN
|
|
|
|
|
DROP PROCEDURE dbo.PGetBizConfig
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE PROCEDURE PGetBizConfig
|
|
|
|
|
(
|
|
|
|
|
@CompId BIGINT, --<EFBFBD><EFBFBD>˾ID
|
|
|
|
|
@Key VARCHAR(128), --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
@Value VARCHAR(1024) OUTPUT --<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
)
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
IF OBJECT_ID('TBizConfig') IS NOT NULL AND EXISTS(SELECT 1 FROM TBizConfig)
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Value = ISNULL(FValue,'') FROM TBizConfig WITH(NOLOCK) WHERE FKey = @Key AND FCompId = @CompId
|
|
|
|
|
RETURN
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
IF @CompId = 1 --<EFBFBD>ܹ<EFBFBD>˾
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Value = ISNULL(FValue,'') FROM TSystemParam WITH(NOLOCK) WHERE FKey = @Key
|
|
|
|
|
END
|
|
|
|
|
ELSE
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Value = ISNULL(TB.FValue,T.FValue)
|
|
|
|
|
FROM TSystemParam AS T
|
|
|
|
|
LEFT JOIN TSystemParamSub AS TB ON TB.FParamKey=T.FKey AND TB.FCompId=@CompId AND T.FKey = TB.FParamKey
|
|
|
|
|
WHERE T.FKey = @Key
|
|
|
|
|
END
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #BizCompany
|
|
|
|
|
DROP TABLE #SMSCompany
|
|
|
|
|
DELETE TBizConfig
|
|
|
|
|
|
|
|
|
|
SELECT B.FCompId INTO #BizCompany
|
|
|
|
|
FROM TSystemParam AS A,TSystemParamSub AS B
|
|
|
|
|
WHERE A.FKey = B.FParamKey
|
|
|
|
|
AND A.FValue != B.FValue
|
|
|
|
|
AND A.FCategory != 'SMS'
|
|
|
|
|
GROUP BY B.FCompId
|
|
|
|
|
|
|
|
|
|
SELECT B.FCompId INTO #SmsCompany
|
|
|
|
|
FROM TSystemParam AS A,TSystemParamSub AS B
|
|
|
|
|
WHERE A.FKey = B.FParamKey
|
|
|
|
|
AND A.FValue != B.FValue
|
|
|
|
|
AND A.FCategory = 'SMS'
|
|
|
|
|
GROUP BY B.FCompId
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ⶼ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT TBasicDataSyncControl (FId,FCompId,FCategory,FMode)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FId,'BizConfig',1
|
|
|
|
|
FROM TCompany AS A
|
|
|
|
|
WHERE A.FId > 0
|
|
|
|
|
AND A.FId NOT IN(SELECT FCompId FROM #BizCompany)
|
|
|
|
|
|
|
|
|
|
INSERT TBasicDataSyncControl (FId,FCompId,FCategory,FMode)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FId,'SMSConfig',1
|
|
|
|
|
FROM TCompany AS A
|
|
|
|
|
WHERE A.FId > 0
|
|
|
|
|
AND A.FId NOT IN(SELECT FCompId FROM #SMSCompany)
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT TBasicDataSyncControl (FId,FCompId,FCategory,FMode)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FId,'BizConfig',0
|
|
|
|
|
FROM TCompany AS A
|
|
|
|
|
WHERE A.FId > 0
|
|
|
|
|
AND A.FId IN(SELECT FCompId FROM #BizCompany)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TBasicDataSyncControl (FId,FCompId,FCategory,FMode)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FId,'SMSConfig',0
|
|
|
|
|
FROM TCompany AS A
|
|
|
|
|
WHERE A.FId > 0
|
|
|
|
|
AND A.FId IN(SELECT FCompId FROM #SMSCompany)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT INTO TBizConfig(FCompId,FKey,FDataType,FValue,FDescription,FCategory)
|
|
|
|
|
SELECT C.FId,A.FKey,A.FDataType,A.FValue,A.FDescription,A.FCategory
|
|
|
|
|
FROM TSystemParam AS A,TCompany AS C
|
|
|
|
|
WHERE A.FCategory != 'SMS'
|
|
|
|
|
AND C.FId NOT IN(SELECT FCompId FROM #BizCompany)
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBizConfig(FCompId,FKey,FDataType,FValue,FDescription,FCategory)
|
|
|
|
|
SELECT C.FId,A.FKey,A.FDataType,A.FValue,A.FDescription,A.FCategory
|
|
|
|
|
FROM TSystemParam AS A,TCompany AS C
|
|
|
|
|
WHERE A.FCategory = 'SMS'
|
|
|
|
|
AND C.FId NOT IN(SELECT FCompId FROM #SMSCompany)
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT INTO TBizConfig(FCompId,FKey,FDataType,FValue,FDescription,FCategory)
|
|
|
|
|
SELECT C.FId,A.FKey,A.FDataType,A.FValue,A.FDescription,A.FCategory
|
|
|
|
|
FROM TSystemParam AS A,TCompany AS C
|
|
|
|
|
WHERE A.FCategory != 'SMS'
|
|
|
|
|
AND C.FId IN(SELECT FCompId FROM #BizCompany)
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBizConfig(FCompId,FKey,FDataType,FValue,FDescription,FCategory)
|
|
|
|
|
SELECT C.FId,A.FKey,A.FDataType,A.FValue,A.FDescription,A.FCategory
|
|
|
|
|
FROM TSystemParam AS A,TCompany AS C
|
|
|
|
|
WHERE A.FCategory = 'SMS'
|
|
|
|
|
AND C.FId IN(SELECT FCompId FROM #SMSCompany)
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|