從 ERP 同步模具/治具基本資料至 MES 的 MoldInfo 和 MoldStatus 資料表。
| ERP 欄位 | MES 欄位 | 說明 |
|---|---|---|
mold_fixture_no | moldId | 模具編號(主鍵) |
mold_fixture_name | moldName | 模具名稱 |
remark | remark | 備註 |
belongings_no | belongings | 歸屬編號 |
supplier_no | productionLine | 生產線編號 |
status | status | 狀態 |
tran_status | TRAN_STATUS | 交易狀態 |
{
"mold_fixture_data": [
{
"mold_fixture_no": "MOLD001",
"mold_fixture_name": "射出模具A",
"remark": "精密塑膠件使用",
"belongings_no": "BELONG01",
"supplier_no": "WS001",
"status": "1",
"modify_no": "USER001",
"tran_status": "AU"
}
]
}
新增模具時會同時建立 MoldStatus 記錄:
| 欄位 | 預設值 | 說明 |
|---|---|---|
| fail | 2 | 失敗次數 |
| produced | 0 | 已生產數量 |
| moldState | 1 | 模具狀態 |
SELECT COUNT(1) FROM MoldInfo WHERE moldId = N'{mold_fixture_no}'
-- count > 0 → UPDATE, count = 0 → INSERT
-- MoldInfo 表
INSERT INTO MoldInfo (
moldId, moldName, remark, belongings, productionLine, status
) VALUES (
:moldId,
:moldName,
:remark,
:belongings,
:productionLine,
:status
)
-- MoldStatus 表(連動建立)
INSERT INTO MoldStatus (moldId, fail, produced, moldState)
VALUES (:moldId, 2, 0, 1)
UPDATE MoldInfo SET
moldName = :moldName,
remark = :remark,
belongings = :belongings,
productionLine = :productionLine,
status = :status
WHERE moldId = :moldId