-- 检查产品交付相关表的 collation（ASNBOLShipperMaster + DepartmentMaster）
USE aidopdev;

SELECT '产品交付涉及的表和字段' AS 检查项;

-- ASNBOLShipperMaster 的 Department 和 Domain
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, COLLATION_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'ASNBOLShipperMaster'
  AND COLUMN_NAME IN ('Department', 'Domain')
ORDER BY COLUMN_NAME;

-- DepartmentMaster 的 Department 和 Domain
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, COLLATION_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'DepartmentMaster'
  AND COLUMN_NAME IN ('Department', 'Domain', 'Descr')
ORDER BY COLUMN_NAME;

-- 也检查 ResourceOccupancyTime 与 LineMaster 可能的 JOIN 字段
SELECT 'ResourceOccupancyTime 与 LineMaster JOIN 字段' AS 检查项;
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, COLLATION_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND ((TABLE_NAME = 'ResourceOccupancyTime' AND COLUMN_NAME IN ('Domain', 'Resource'))
    OR (TABLE_NAME = 'LineMaster' AND COLUMN_NAME IN ('Domain', 'Line')))
ORDER BY TABLE_NAME, COLUMN_NAME;
