|
@ -7,26 +7,15 @@ GO |
|
|
/****** Object: PartitionScheme [part_version_rang_schema] Script Date: 2023/10/8 8:48:30 ******/ |
|
|
/****** Object: PartitionScheme [part_version_rang_schema] Script Date: 2023/10/8 8:48:30 ******/ |
|
|
CREATE PARTITION SCHEME [part_version_rang_schema] AS PARTITION [part_version_rang_func] TO ([PRIMARY], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028]) |
|
|
CREATE PARTITION SCHEME [part_version_rang_schema] AS PARTITION [part_version_rang_func] TO ([PRIMARY], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2022], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2023], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2024], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2025], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2026], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2027], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028], [2028]) |
|
|
GO |
|
|
GO |
|
|
|
|
|
|
|
|
USE [BQ_SA] |
|
|
USE [BQ_SA] |
|
|
GO |
|
|
GO |
|
|
|
|
|
|
|
|
/****** Object: PartitionFunction [part_version_rang_func] Script Date: 2023/10/8 8:49:27 ******/ |
|
|
/****** Object: PartitionFunction [part_version_rang_func] Script Date: 2023/10/8 8:49:27 ******/ |
|
|
DROP PARTITION FUNCTION [part_version_rang_func] |
|
|
DROP PARTITION FUNCTION [part_version_rang_func] |
|
|
GO |
|
|
GO |
|
|
|
|
|
|
|
|
/****** Object: PartitionFunction [part_version_rang_func] Script Date: 2023/10/8 8:49:27 ******/ |
|
|
/****** Object: PartitionFunction [part_version_rang_func] Script Date: 2023/10/8 8:49:27 ******/ |
|
|
CREATE PARTITION FUNCTION [part_version_rang_func](int) AS RANGE LEFT FOR VALUES (201801, 201802, 201803, 201804, 201805, 201806, 201807, 201808, 201809, 201810, 201811, 201812, 201901, 201902, 201903, 201904, 201905, 201906, 201907, 201908, 201909, 201910, 201911, 201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007, 202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103, 202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111, 202112, 202201, 202202, 202203, 202204, 202205, 202206, 202207, 202208, 202209, 202210, 202211, 202212, 202301, 202302, 202303, 202304, 202305, 202306, 202307, 202308, 202309, 202310, 202311, 202312, 202401, 202402, 202403, 202404, 202405, 202406, 202407, 202408, 202409, 202410, 202411, 202412, 202501, 202502, 202503, 202504, 202505, 202506, 202507, 202508, 202509, 202510, 202511, 202512, 202601, 202602, 202603, 202604, 202605, 202606, 202607, 202608, 202609, 202610, 202611, 202612, 202701, 202702, 202703, 202704, 202705, 202706, 202707, 202708, 202709, 202710, 202711, 202712, 202801, 202802, 202803, 202804, 202805, 202806, 202807, 202808, 202809, 202810, 202811, 202812) |
|
|
CREATE PARTITION FUNCTION [part_version_rang_func](int) AS RANGE LEFT FOR VALUES (201801, 201802, 201803, 201804, 201805, 201806, 201807, 201808, 201809, 201810, 201811, 201812, 201901, 201902, 201903, 201904, 201905, 201906, 201907, 201908, 201909, 201910, 201911, 201912, 202001, 202002, 202003, 202004, 202005, 202006, 202007, 202008, 202009, 202010, 202011, 202012, 202101, 202102, 202103, 202104, 202105, 202106, 202107, 202108, 202109, 202110, 202111, 202112, 202201, 202202, 202203, 202204, 202205, 202206, 202207, 202208, 202209, 202210, 202211, 202212, 202301, 202302, 202303, 202304, 202305, 202306, 202307, 202308, 202309, 202310, 202311, 202312, 202401, 202402, 202403, 202404, 202405, 202406, 202407, 202408, 202409, 202410, 202411, 202412, 202501, 202502, 202503, 202504, 202505, 202506, 202507, 202508, 202509, 202510, 202511, 202512, 202601, 202602, 202603, 202604, 202605, 202606, 202607, 202608, 202609, 202610, 202611, 202612, 202701, 202702, 202703, 202704, 202705, 202706, 202707, 202708, 202709, 202710, 202711, 202712, 202801, 202802, 202803, 202804, 202805, 202806, 202807, 202808, 202809, 202810, 202811, 202812) |
|
|
GO |
|
|
GO |
|
|
|
|
|
# 脚本中数据[BJEDI]内置字符串分表 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 脚本中数据[BJEDI],需要批量替换成EDI数据库名 |
|
|
|
|
|
# 例如:[10.62.103.22].[EDI] |
|
|
|
|
|
|
|
|
|
|
|
USE [BQ_SA] |
|
|
USE [BQ_SA] |
|
|
GO |
|
|
GO |
|
@ -88,85 +77,245 @@ end |
|
|
return |
|
|
return |
|
|
end |
|
|
end |
|
|
GO |
|
|
GO |
|
|
/****** Object: StoredProcedure [dbo].[p_get_bbac_jis_edi] Script Date: 2023/10/8 8:42:20 ******/ |
|
|
# EDI同步脚本脚本中数据[BJEDI],需要批量替换成EDI数据库名 |
|
|
SET ANSI_NULLS ON |
|
|
# 例如:[10.62.103.22].[EDI] |
|
|
|
|
|
|
|
|
|
|
|
# 自动同步BBAC_EDI数据 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****** Object: StoredProcedure [dbo].[p_bbac_edi] Script Date: 2023/10/20 14:06:21 ******/ |
|
|
|
|
|
SET |
|
|
|
|
|
ANSI_NULLS ON |
|
|
GO |
|
|
GO |
|
|
SET QUOTED_IDENTIFIER ON |
|
|
SET |
|
|
|
|
|
QUOTED_IDENTIFIER ON |
|
|
GO |
|
|
GO |
|
|
|
|
|
|
|
|
|
|
|
CREATE proc [dbo].[p_bbac_edi] |
|
|
|
|
|
@begindate datetime, |
|
|
|
|
|
@enddate datetime |
|
|
|
|
|
AS |
|
|
|
|
|
BEGIN |
|
|
|
|
|
TRY |
|
|
|
|
|
|
|
|
CREATE proc [dbo].[p_get_bbac_jis_edi] |
|
|
|
|
|
as |
|
|
|
|
|
BEGIN TRY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT |
|
|
|
|
|
* |
|
|
|
|
|
INTO |
|
|
|
|
|
#temp_bbac |
|
|
|
|
|
FROM |
|
|
|
|
|
( |
|
|
|
|
|
SELECT |
|
|
|
|
|
* |
|
|
|
|
|
FROM |
|
|
|
|
|
[10.60.5.60].[BJEDI].[dbo].[View_BBAC_JIS] |
|
|
|
|
|
) a |
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_BBAC_SE_EDI a |
|
|
|
|
|
USING #temp_bbac b |
|
|
|
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
|
|
|
AND b.Version>a.VERSION |
|
|
|
|
|
WHEN MATCHED THEN |
|
|
|
|
|
UPDATE |
|
|
|
|
|
SET |
|
|
|
|
|
a.IsDeleted = 1; |
|
|
|
|
|
|
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_BBAC_SE_EDI a |
|
|
|
|
|
USING #temp_bbac b |
|
|
|
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
|
|
|
AND b.Version = a.VERSION |
|
|
|
|
|
AND a.LU = B.LU |
|
|
|
|
|
WHEN NOT MATCHED THEN |
|
|
|
|
|
|
|
|
select * into #temp_bbac from ( |
|
|
INSERT |
|
|
|
|
|
( |
|
|
|
|
|
|
|
|
SELECT * FROM |
|
|
[Id] |
|
|
[BJEDI].[dbo].[View_BBAC_JIS] |
|
|
, |
|
|
|
|
|
[KeyCode] |
|
|
|
|
|
, |
|
|
|
|
|
[Version] |
|
|
|
|
|
, |
|
|
|
|
|
[LU] |
|
|
|
|
|
, |
|
|
|
|
|
[PN] |
|
|
|
|
|
, |
|
|
|
|
|
[SeqNumber] |
|
|
|
|
|
, |
|
|
|
|
|
[AssemblyCode] |
|
|
|
|
|
, |
|
|
|
|
|
[InjectionCode] |
|
|
|
|
|
, |
|
|
|
|
|
[Qty] |
|
|
|
|
|
, |
|
|
|
|
|
[BeginDate] |
|
|
|
|
|
, |
|
|
|
|
|
[CreationTime] |
|
|
|
|
|
, |
|
|
|
|
|
[CreatorId] |
|
|
|
|
|
, |
|
|
|
|
|
[IsDeleted] |
|
|
|
|
|
, |
|
|
|
|
|
[Extend1] |
|
|
|
|
|
, |
|
|
|
|
|
[Extend2] |
|
|
|
|
|
, |
|
|
|
|
|
[Extend3] |
|
|
|
|
|
, |
|
|
|
|
|
[Extend4] |
|
|
|
|
|
, |
|
|
|
|
|
[lineStationCode] |
|
|
|
|
|
, |
|
|
|
|
|
CustomerPartCodeNoSpace |
|
|
|
|
|
) |
|
|
|
|
|
VALUES |
|
|
|
|
|
(newid() , |
|
|
|
|
|
KeyCode, |
|
|
|
|
|
Version, |
|
|
|
|
|
LU, |
|
|
|
|
|
PN, |
|
|
|
|
|
SeqNumber, |
|
|
|
|
|
[AssemblyCode] , |
|
|
|
|
|
[InjectionCode], |
|
|
|
|
|
Qty, |
|
|
|
|
|
BeginDate, |
|
|
|
|
|
CreationTime, |
|
|
|
|
|
newid(), |
|
|
|
|
|
0, |
|
|
|
|
|
Extend1, |
|
|
|
|
|
Extend2, |
|
|
|
|
|
Extend3, |
|
|
|
|
|
Extend4, |
|
|
|
|
|
[lineStationCode], |
|
|
|
|
|
CustomerPartCodeNoSpace |
|
|
|
|
|
); |
|
|
|
|
|
END TRY |
|
|
|
|
|
BEGIN |
|
|
|
|
|
CATCH |
|
|
|
|
|
SELECT |
|
|
|
|
|
ERROR_NUMBER() AS ErrorNumber, |
|
|
|
|
|
ERROR_MESSAGE() AS ErrorMessage; |
|
|
|
|
|
END CATCH; |
|
|
|
|
|
|
|
|
/* |
|
|
DROP TABLE #temp_bbac |
|
|
|
|
|
GO |
|
|
|
|
|
|
|
|
select RIGHT( REPLACE(CONVERT(varchar(10), a.time , 23),'-',''),6) Version, |
|
|
# 手工同步BBAC_EDI数据 |
|
|
a.time CreationTime , |
|
|
|
|
|
cast(B.productionNumber as varchar(50)) PN, |
|
|
|
|
|
cast(B.itemNumber as varchar(50)) LU, |
|
|
|
|
|
B.quantity Qty, |
|
|
|
|
|
cast( B.sequenceNumber as varchar(50)) SeqNumber, |
|
|
|
|
|
B.assemblyDate BeginDate, |
|
|
|
|
|
|
|
|
|
|
|
A.CarModelCode Extend4, |
|
|
/****** Object: StoredProcedure [dbo].[p_bbacimport] 手动同步BBAC,EDI数据 Script Date: 2023/10/20 14:06:21 ******/ |
|
|
A.productionPoint Site, |
|
|
SET |
|
|
|
|
|
ANSI_NULLS ON |
|
|
|
|
|
GO |
|
|
|
|
|
SET |
|
|
|
|
|
QUOTED_IDENTIFIER ON |
|
|
|
|
|
GO |
|
|
|
|
|
CREATE proc [dbo].[p_bbacimport] |
|
|
|
|
|
@begindate datetime, |
|
|
|
|
|
@enddate datetime |
|
|
|
|
|
|
|
|
|
|
|
AS |
|
|
|
|
|
BEGIN TRY |
|
|
|
|
|
|
|
|
A.BillNo Extend1, |
|
|
SELECT |
|
|
a.partType Extend2, |
|
|
* |
|
|
a.LastSequence Extend3, |
|
|
INTO |
|
|
A.MatchNumber AssemblyCode, |
|
|
#temp_bbac |
|
|
A.BarCode [InjectionCode], |
|
|
FROM |
|
|
|
|
|
( |
|
|
|
|
|
SELECT |
|
|
|
|
|
RIGHT(REPLACE(CONVERT(varchar(10), |
|
|
|
|
|
a.time, |
|
|
|
|
|
23), |
|
|
|
|
|
'-', |
|
|
|
|
|
''), |
|
|
|
|
|
6) AS Version, |
|
|
|
|
|
ISNULL(a.time, |
|
|
|
|
|
GETDATE()) AS CreationTime, |
|
|
|
|
|
CAST(b.productionNumber AS varchar(50)) AS PN, |
|
|
|
|
|
b.itemNumber AS LU, |
|
|
|
|
|
b.quantity AS Qty, |
|
|
|
|
|
CAST(b.sequenceNumber AS varchar(50)) AS SeqNumber, |
|
|
|
|
|
ISNULL(b.assemblyDate, |
|
|
|
|
|
GETDATE()) AS BeginDate, |
|
|
|
|
|
a.CarModelCode AS Extend4, |
|
|
|
|
|
a.productionPoint AS Site, |
|
|
|
|
|
a.BillNo AS Extend1, |
|
|
|
|
|
a.partType AS Extend2, |
|
|
|
|
|
a.LastSequence AS Extend3, |
|
|
|
|
|
a.BarCode AS InjectionCode, |
|
|
|
|
|
b.总成号 AS AssemblyCode, |
|
|
|
|
|
b.lineStationCode, |
|
|
|
|
|
REPLACE(ISNULL(a.productionNumber, |
|
|
|
|
|
''), |
|
|
|
|
|
' ', |
|
|
|
|
|
'') + REPLACE(ISNULL(a.itemNumber, |
|
|
|
|
|
''), |
|
|
|
|
|
' ', |
|
|
|
|
|
'') AS KeyCode, |
|
|
|
|
|
REPLACE(b.itemNumber, |
|
|
|
|
|
' ', |
|
|
|
|
|
'') AS CustomerPartCodeNoSpace |
|
|
|
|
|
FROM |
|
|
|
|
|
[10.60.5.60].[BJEDI].dbo.t_Edi_Actual AS a WITH (nolock) |
|
|
|
|
|
INNER JOIN |
|
|
|
|
|
[10.60.5.60].[BJEDI].dbo.t_Edi_Planned AS b WITH (nolock) ON |
|
|
|
|
|
a.productionNumber = b.productionNumber |
|
|
|
|
|
AND a.partType = b.partType |
|
|
|
|
|
WHERE |
|
|
|
|
|
a.AssemblyDate >= @begindate |
|
|
|
|
|
AND a.AssemblyDate <= @enddate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(REPLACE(isnull(A.[productionNumber],''),' ','') + REPLACE(isnull(A.[itemNumber],''),' ','')) KeyCode |
|
|
|
|
|
from t_Edi_Actual a |
|
|
|
|
|
inner join t_Edi_Planned b |
|
|
|
|
|
on a.productionNumber=b.productionNumber and a.partType=b.partType |
|
|
|
|
|
*/ |
|
|
|
|
|
) a |
|
|
) a |
|
|
|
|
|
|
|
|
MERGE INTO Set_BBAC_SE_EDI a |
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_BBAC_SE_EDI a |
|
|
USING #temp_bbac b |
|
|
USING #temp_bbac b |
|
|
on b.PN=a.PN |
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
AND b.Version>a.VERSION |
|
|
AND b.Version>a.VERSION |
|
|
when Matched then |
|
|
WHEN MATCHED THEN |
|
|
update set a.IsDeleted=1; |
|
|
UPDATE |
|
|
|
|
|
SET |
|
|
|
|
|
a.IsDeleted = 1; |
|
|
MERGE INTO Set_BBAC_SE_EDI a |
|
|
|
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_BBAC_SE_EDI a |
|
|
USING #temp_bbac b |
|
|
USING #temp_bbac b |
|
|
on b.PN=a.PN |
|
|
ON |
|
|
AND b.Version=a.VERSION and a.LU=B.LU |
|
|
b.PN = a.PN |
|
|
when NOT MATCHED then |
|
|
AND b.Version = a.VERSION |
|
|
|
|
|
AND a.LU = B.LU |
|
|
|
|
|
WHEN NOT MATCHED THEN |
|
|
|
|
|
|
|
|
INSERT |
|
|
INSERT |
|
|
( |
|
|
( |
|
|
[Id] |
|
|
[Id], |
|
|
,[KeyCode] |
|
|
[KeyCode], |
|
|
,[Version] |
|
|
[Version], |
|
|
,[LU] |
|
|
[LU], |
|
|
,[PN] |
|
|
[PN], |
|
|
,[SeqNumber] |
|
|
[SeqNumber], |
|
|
,[AssemblyCode] |
|
|
[AssemblyCode], |
|
|
,[InjectionCode] |
|
|
[InjectionCode], |
|
|
,[Qty] |
|
|
[Qty], |
|
|
,[BeginDate] |
|
|
[BeginDate], |
|
|
,[CreationTime] |
|
|
[CreationTime], |
|
|
,[CreatorId] |
|
|
[CreatorId], |
|
|
,[IsDeleted] |
|
|
[IsDeleted], |
|
|
,[Extend1] |
|
|
[Extend1], |
|
|
,[Extend2] |
|
|
[Extend2], |
|
|
,[Extend3] |
|
|
[Extend3], |
|
|
,[Extend4] |
|
|
[Extend4], |
|
|
,[lineStationCode] |
|
|
[lineStationCode], |
|
|
,CustomerPartCodeNoSpace |
|
|
CustomerPartCodeNoSpace |
|
|
) |
|
|
) |
|
|
VALUES |
|
|
VALUES |
|
|
(newid() , |
|
|
(newid() , |
|
@ -189,82 +338,79 @@ when NOT MATCHED then |
|
|
[lineStationCode], |
|
|
[lineStationCode], |
|
|
CustomerPartCodeNoSpace |
|
|
CustomerPartCodeNoSpace |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END TRY |
|
|
END TRY |
|
|
BEGIN CATCH |
|
|
BEGIN |
|
|
SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage; |
|
|
CATCH |
|
|
|
|
|
SELECT |
|
|
|
|
|
ERROR_NUMBER() AS ErrorNumber, |
|
|
|
|
|
ERROR_MESSAGE() AS ErrorMessage; |
|
|
END CATCH; |
|
|
END CATCH; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #temp_bbac |
|
|
DROP TABLE #temp_bbac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO |
|
|
GO |
|
|
/****** Object: StoredProcedure [dbo].[p_get_hbpo_jis_edi] Script Date: 2023/10/8 8:42:20 ******/ |
|
|
# 自动同步HBPO_EDI数据 |
|
|
SET ANSI_NULLS ON |
|
|
/****** Object: StoredProcedure [dbo].[p_hbpo_edi] 自动同步HBPO EDI数据 Script Date: 2023/10/20 14:06:21 ******/ |
|
|
|
|
|
SET |
|
|
|
|
|
ANSI_NULLS ON |
|
|
GO |
|
|
GO |
|
|
SET QUOTED_IDENTIFIER ON |
|
|
SET |
|
|
|
|
|
QUOTED_IDENTIFIER ON |
|
|
GO |
|
|
GO |
|
|
|
|
|
CREATE proc [dbo].[p_hbpo_edi] |
|
|
CREATE proc [dbo].[p_get_hbpo_jis_edi] |
|
|
@BeginDate varchar(50) , |
|
|
|
|
|
@EndDate varchar(50) |
|
|
|
|
|
AS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
as |
|
|
|
|
|
BEGIN TRY |
|
|
BEGIN TRY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * into #temp_hbpo from |
|
|
SELECT |
|
|
|
|
|
* |
|
|
|
|
|
INTO |
|
|
|
|
|
#temp_hbpo |
|
|
|
|
|
FROM |
|
|
( |
|
|
( |
|
|
SELECT * FROM |
|
|
SELECT |
|
|
[BJEDI].[dbo].[View_HBPO_JIS] |
|
|
* |
|
|
|
|
|
FROM |
|
|
|
|
|
[10.60.5.60].[BJEDI].[dbo].[View_HBPO_JIS] |
|
|
--select [AddTime] CreationTime, [BillNo] SeqNumber, A.[Production no#] PN, [Shift no#] InjectionCode, [Date of JIS call] Version,[Part number] LU, |
|
|
|
|
|
--Quantity Qty,(REPLACE(isnull(A.[Production no#],''),' ','') + REPLACE(isnull([Part number],''),' ','')) KeyCode |
|
|
|
|
|
--from |
|
|
|
|
|
--t_MqDetail a |
|
|
|
|
|
--inner join |
|
|
|
|
|
--t_MqHead b |
|
|
|
|
|
--on a.[Production no#]=b.[Production no#] |
|
|
|
|
|
) a |
|
|
) a |
|
|
|
|
|
MERGE |
|
|
MERGE INTO Set_HBPO_SE_EDI a |
|
|
INTO |
|
|
|
|
|
Set_HBPO_SE_EDI a |
|
|
USING #temp_hbpo b |
|
|
USING #temp_hbpo b |
|
|
on b.PN=a.PN |
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
AND b.Version>a.VERSION |
|
|
AND b.Version>a.VERSION |
|
|
when Matched then |
|
|
WHEN MATCHED THEN |
|
|
update set a.IsDeleted=1; |
|
|
UPDATE |
|
|
|
|
|
SET |
|
|
|
|
|
a.IsDeleted = 1; |
|
|
MERGE INTO Set_HBPO_SE_EDI a |
|
|
|
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_HBPO_SE_EDI a |
|
|
USING #temp_hbpo b |
|
|
USING #temp_hbpo b |
|
|
on b.PN=a.PN |
|
|
ON |
|
|
AND b.Version=a.VERSION and a.LU=B.LU |
|
|
b.PN = a.PN |
|
|
when NOT MATCHED then |
|
|
AND b.Version = a.VERSION |
|
|
|
|
|
AND a.LU = B.LU |
|
|
|
|
|
WHEN NOT MATCHED THEN |
|
|
|
|
|
|
|
|
INSERT |
|
|
INSERT |
|
|
([Id] |
|
|
([Id], |
|
|
,[KeyCode] |
|
|
[KeyCode], |
|
|
,[Version] |
|
|
[Version], |
|
|
,[LU] |
|
|
[LU], |
|
|
,[PN] |
|
|
[PN], |
|
|
,[SeqNumber] |
|
|
[SeqNumber], |
|
|
,[AssemblyCode] |
|
|
[AssemblyCode], |
|
|
,[InjectionCode] |
|
|
[InjectionCode], |
|
|
,[Qty] |
|
|
[Qty], |
|
|
,[BeginDate] |
|
|
[BeginDate], |
|
|
|
|
|
[CreationTime], |
|
|
,[CreationTime] |
|
|
[CreatorId], |
|
|
,[CreatorId] |
|
|
[IsDeleted], |
|
|
|
|
|
CustomerPartCodeNoSpace |
|
|
,[IsDeleted] |
|
|
|
|
|
,CustomerPartCodeNoSpace |
|
|
|
|
|
) |
|
|
) |
|
|
VALUES |
|
|
VALUES |
|
|
(newid() , |
|
|
(newid() , |
|
@ -281,164 +427,158 @@ when NOT MATCHED then |
|
|
newid(), |
|
|
newid(), |
|
|
0, |
|
|
0, |
|
|
CustomerPartCodeNoSpace |
|
|
CustomerPartCodeNoSpace |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END TRY |
|
|
END TRY |
|
|
BEGIN CATCH |
|
|
BEGIN |
|
|
SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage; |
|
|
CATCH |
|
|
|
|
|
SELECT |
|
|
|
|
|
ERROR_NUMBER() AS ErrorNumber, |
|
|
|
|
|
ERROR_MESSAGE() AS ErrorMessage; |
|
|
END CATCH; |
|
|
END CATCH; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #temp_hbpo |
|
|
DROP TABLE #temp_hbpo |
|
|
|
|
|
|
|
|
GO |
|
|
GO |
|
|
/****** Object: StoredProcedure [dbo].[p_Invoice_generation_change] Script Date: 2023/10/8 8:42:20 ******/ |
|
|
|
|
|
SET ANSI_NULLS ON |
|
|
|
|
|
GO |
|
|
|
|
|
SET QUOTED_IDENTIFIER ON |
|
|
|
|
|
GO |
|
|
|
|
|
-- ============================================= |
|
|
|
|
|
|
|
|
|
|
|
-- Author: <Author,,Name> |
|
|
|
|
|
|
|
|
|
|
|
-- Create date: <Create Date,,> |
|
|
|
|
|
|
|
|
|
|
|
-- Description: <Description,,> |
|
|
|
|
|
|
|
|
|
|
|
-- ============================================= |
|
|
|
|
|
|
|
|
|
|
|
CREATE PROCEDURE [dbo].[p_Invoice_generation_change] |
|
|
|
|
|
|
|
|
|
|
|
@invbillnum varchar(50), |
|
|
|
|
|
|
|
|
|
|
|
@groupNum varchar(max), |
|
|
|
|
|
|
|
|
|
|
|
@businessType varchar(50) |
|
|
|
|
|
|
|
|
|
|
|
AS |
|
|
|
|
|
|
|
|
|
|
|
BEGIN |
|
|
|
|
|
|
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from |
|
|
|
|
|
|
|
|
|
|
|
-- interfering with SELECT statements. |
|
|
|
|
|
|
|
|
|
|
|
SET NOCOUNT ON; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE Set_BBAC_CAN_SA_DETAIL SET InvbillNum=@invbillnum FROM Set_BBAC_CAN_SA_DETAIL T1 |
|
|
|
|
|
|
|
|
|
|
|
INNER JOIN |
|
|
|
|
|
|
|
|
|
|
|
(select c1 from func_splitstring(@groupNum,',')) T2 ON T1.GroupNum=T2.c1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET NOCOUNT OFF; |
|
|
# 手工同步HBPO_EDI数据 |
|
|
|
|
|
|
|
|
END |
|
|
/****** Object: StoredProcedure [dbo].[p_importhbpo] 手工HBPO同步数据 Script Date: 2023/10/20 14:06:21 ******/ |
|
|
|
|
|
SET |
|
|
GO |
|
|
ANSI_NULLS ON |
|
|
/****** Object: StoredProcedure [dbo].[p_reBuildIndex] Script Date: 2023/10/8 8:42:20 ******/ |
|
|
|
|
|
SET ANSI_NULLS ON |
|
|
|
|
|
GO |
|
|
GO |
|
|
SET QUOTED_IDENTIFIER ON |
|
|
SET |
|
|
|
|
|
QUOTED_IDENTIFIER ON |
|
|
GO |
|
|
GO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE proc [dbo].[p_importhbpo] |
|
|
|
|
|
|
|
|
|
|
|
@BeginDate varchar(50) , |
|
|
|
|
|
@EndDate varchar(50) |
|
|
|
|
|
|
|
|
CREATE proc [dbo].[p_reBuildIndex] |
|
|
|
|
|
|
|
|
|
|
|
as |
|
|
|
|
|
|
|
|
|
|
|
declare @statement NVARCHAR(1000) |
|
|
|
|
|
|
|
|
|
|
|
declare mycursor cursor for |
|
|
|
|
|
|
|
|
|
|
|
SELECT 'ALTER INDEX [' + ix.name + '] ON [' + s.name + '].[' + t.name + '] REBUILD WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, SORT_IN_TEMPDB = OFF, ONLINE = OFF )' |
|
|
|
|
|
|
|
|
|
|
|
as sqlStr |
|
|
|
|
|
|
|
|
|
|
|
FROM sys.indexes AS ix |
|
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys.tables t |
|
|
|
|
|
|
|
|
|
|
|
ON t.object_id = ix.object_id |
|
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys.schemas s |
|
|
|
|
|
|
|
|
|
|
|
ON t.schema_id = s.schema_id |
|
|
|
|
|
|
|
|
|
|
|
INNER JOIN |
|
|
|
|
|
|
|
|
|
|
|
(SELECT object_id , |
|
|
|
|
|
|
|
|
|
|
|
index_id , |
|
|
|
|
|
|
|
|
|
|
|
avg_fragmentation_in_percent, |
|
|
|
|
|
|
|
|
|
|
|
partition_number |
|
|
|
|
|
|
|
|
|
|
|
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) |
|
|
|
|
|
|
|
|
|
|
|
) ps |
|
|
|
|
|
|
|
|
|
|
|
ON t.object_id = ps.object_id |
|
|
|
|
|
|
|
|
|
|
|
AND ix.index_id = ps.index_id |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AS |
|
|
|
|
|
BEGIN TRY |
|
|
|
|
|
SELECT |
|
|
|
|
|
* |
|
|
|
|
|
INTO |
|
|
|
|
|
#temp_hbpo |
|
|
|
|
|
FROM |
|
|
|
|
|
( |
|
|
|
|
|
SELECT |
|
|
|
|
|
b.AddTime AS CreationTime, |
|
|
|
|
|
b.BillNo AS SeqNumber, |
|
|
|
|
|
a.[Production no.] AS PN, |
|
|
|
|
|
b.[Shift no.] AS InjectionCode, |
|
|
|
|
|
b.[Date OF JIS CALL] AS Version, |
|
|
|
|
|
a.[Part number] AS LU, |
|
|
|
|
|
a.Quantity AS Qty, |
|
|
|
|
|
REPLACE(ISNULL(a.[Production no.], |
|
|
|
|
|
N''), |
|
|
|
|
|
' ', |
|
|
|
|
|
'') |
|
|
|
|
|
+ REPLACE(ISNULL(a.[Part number], |
|
|
|
|
|
N''), |
|
|
|
|
|
' ', |
|
|
|
|
|
'') |
|
|
|
|
|
AS KeyCode, |
|
|
|
|
|
REPLACE(a.[Part number], |
|
|
|
|
|
' ', |
|
|
|
|
|
'') AS CustomerPartCodeNoSpace |
|
|
|
|
|
FROM |
|
|
|
|
|
[10.60.5.60].[BJEDI].dbo.t_MqDetail AS a WITH (nolock) |
|
|
INNER JOIN |
|
|
INNER JOIN |
|
|
|
|
|
[10.60.5.60].[BJEDI].dbo.t_MqHead AS b WITH (nolock) ON |
|
|
|
|
|
a.[Production no.] = b.[Production no.] |
|
|
|
|
|
WHERE |
|
|
|
|
|
b.[Date OF JIS CALL]>= @BeginDate |
|
|
|
|
|
AND b.[Date OF JIS CALL]<= @EndDate |
|
|
|
|
|
) a |
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_HBPO_SE_EDI a |
|
|
|
|
|
USING #temp_hbpo b |
|
|
|
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
|
|
|
AND b.Version>a.VERSION |
|
|
|
|
|
WHEN MATCHED THEN |
|
|
|
|
|
UPDATE |
|
|
|
|
|
SET |
|
|
|
|
|
a.IsDeleted = 1; |
|
|
|
|
|
|
|
|
|
|
|
MERGE |
|
|
|
|
|
INTO |
|
|
|
|
|
Set_HBPO_SE_EDI a |
|
|
|
|
|
USING #temp_hbpo b |
|
|
|
|
|
ON |
|
|
|
|
|
b.PN = a.PN |
|
|
|
|
|
AND b.Version = a.VERSION |
|
|
|
|
|
AND a.LU = B.LU |
|
|
|
|
|
WHEN NOT MATCHED THEN |
|
|
|
|
|
|
|
|
(SELECT object_id, |
|
|
INSERT |
|
|
|
|
|
([Id] |
|
|
index_id , |
|
|
, |
|
|
|
|
|
[KeyCode] |
|
|
COUNT(DISTINCT partition_number) AS partition_count |
|
|
, |
|
|
|
|
|
[Version] |
|
|
FROM sys.partitions |
|
|
, |
|
|
|
|
|
[LU] |
|
|
GROUP BY object_id, |
|
|
, |
|
|
|
|
|
[PN] |
|
|
index_id |
|
|
, |
|
|
|
|
|
[SeqNumber] |
|
|
) pc |
|
|
, |
|
|
|
|
|
[AssemblyCode] |
|
|
ON t.object_id = pc.object_id |
|
|
, |
|
|
|
|
|
[InjectionCode] |
|
|
AND ix.index_id = pc.index_id |
|
|
, |
|
|
|
|
|
[Qty] |
|
|
WHERE ps.avg_fragmentation_in_percent > 0 |
|
|
, |
|
|
|
|
|
[BeginDate] |
|
|
AND ix.name IS NOT NULL |
|
|
|
|
|
|
|
|
, |
|
|
open mycursor |
|
|
[CreationTime] |
|
|
|
|
|
, |
|
|
|
|
|
[CreatorId] |
|
|
|
|
|
|
|
|
fetch next from mycursor into @statement |
|
|
, |
|
|
|
|
|
[IsDeleted] |
|
|
while(@@fetch_status=0) --如果数据集里一直有数据 |
|
|
, |
|
|
|
|
|
CustomerPartCodeNoSpace |
|
|
begin |
|
|
) |
|
|
|
|
|
VALUES |
|
|
|
|
|
(newid() , |
|
|
|
|
|
KeyCode, |
|
|
|
|
|
Version, |
|
|
|
|
|
LU, |
|
|
|
|
|
PN, |
|
|
|
|
|
SeqNumber, |
|
|
|
|
|
'', |
|
|
|
|
|
InjectionCode, |
|
|
|
|
|
Qty, |
|
|
|
|
|
CreationTime, |
|
|
|
|
|
CreationTime, |
|
|
|
|
|
newid(), |
|
|
|
|
|
0, |
|
|
|
|
|
CustomerPartCodeNoSpace |
|
|
|
|
|
); |
|
|
|
|
|
END TRY |
|
|
|
|
|
BEGIN |
|
|
|
|
|
CATCH |
|
|
|
|
|
SELECT |
|
|
|
|
|
ERROR_NUMBER() AS ErrorNumber, |
|
|
|
|
|
ERROR_MESSAGE() AS ErrorMessage; |
|
|
|
|
|
END CATCH; |
|
|
|
|
|
|
|
|
EXEC sp_executesql @statement |
|
|
DROP TABLE #temp_hbpo |
|
|
|
|
|
|
|
|
--select @statement |
|
|
GO |
|
|
|
|
|
|
|
|
fetch next from mycursor into @statement |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
close mycursor |
|
|
|
|
|
|
|
|
|
|
|
deallocate mycursor |
|
|
|
|
|
|
|
|
|
|
|
GO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|