← 返回 API 列表

模具基本資料

GET ERP → MES
mold.fixture.get

從 ERP 同步模具/治具基本資料至 MES 的 MoldInfo 和 MoldStatus 資料表。

基本資訊

API 名稱
mold.fixture.get
方法名稱
upMoldInfoCROSS
目標資料表
MoldInfo / MoldStatus
JSON 節點
mold_fixture_data
主鍵
moldId (mold_fixture_no)
程式位置
RegularESB.java:3728

回應欄位

ERP 欄位MES 欄位說明
mold_fixture_nomoldId模具編號(主鍵)
mold_fixture_namemoldName模具名稱
remarkremark備註
belongings_nobelongings歸屬編號
supplier_noproductionLine生產線編號
statusstatus狀態
tran_statusTRAN_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 預設值

新增模具時會同時建立 MoldStatus 記錄:

欄位預設值說明
fail2失敗次數
produced0已生產數量
moldState1模具狀態

資料庫更新 SQL

判斷新增或修改

SELECT COUNT(1) FROM MoldInfo WHERE moldId = N'{mold_fixture_no}'
-- count > 0 → UPDATE, count = 0 → INSERT

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(修改模具)

UPDATE MoldInfo SET
    moldName = :moldName,
    remark = :remark,
    belongings = :belongings,
    productionLine = :productionLine,
    status = :status
WHERE moldId = :moldId