lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
ÿþ--[[
 x: GT-100-10
  Tðy: 008-“^X[^\'`¶r`lûy
 \O€: LZH
 eQãSýQpeÿStateTransition
 ŸRý€ô‹f: Çyb!k÷S + ir™exîO9eøvsQ„vyb^\'`
     “eQpencÿ                                                                                        
    {    
        "batch_no": "xxx",    yb!k÷S
        "item_code": "xxx",    ir™ex
        "product_date": "xxx",    u§Nåeg
        "wheel_type_rot": "xxx",    n‹W/æ]óSËe
        "storage_loc": "xxx",    “^MO
        "level": "xxx",    ö€„vI{§~
        "vendor": "xxx",    ›O”^FU
        "subpool": "xxx",    P[“^
        "item_state": "xxx", (Ï‘¶r`
        "expire_date":"", 0Rgöeô•
        "remark1": "",  -- Yèl ‚f*g/T(u
        "remark2": "",  -- Yèl ‚f*g/T(u
        "remark3": "",  -- Yèl ‚f*g/T(u
        "remark4": ""   -- Yèl ‚f*g/T(u
    }    
 
    Yt;‘
        -- step1 ã‰g¥cãS O„v datajson ÂSpe
        -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
        -- step3 Ç yb!k÷S+ir™ex îO9e 0eQ“^USnc4Y0+0eQ“^USncLˆ0^\'`áOo`
 
    ØSôf†SòS:
    20250221 LZH V1.1 °ežX4*NY(uW[µk
 --]]
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
function StateTransition(strLuaDEID)
    local nRet, strRetInfo, in_date
    -- step1 ·ƒÖS¥cãSpenc
    nRet, in_date = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), '“^X[^\'`¶r`lûyÂSpe:', in_date)
 
    -- step2 $R­e Å_kXy˜ /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local batch_no = in_date.batch_no
    if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz!") end
    local item_code = in_date.item_code
    if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzz!") end
    local product_date = in_date.product_date
    local storage_loc = in_date.storage_loc
    local level = in_date.level
    local vendor = in_date.vendor
    local subpool = in_date.subpool
    local item_state = in_date.item_state
    local wheel_type_rot = in_date.wheel_type_rot
    local expire_date = in_date.expire_date
    -- V1.1 °ežXY(uW[µk
    local remark1 = in_date.remark1
    local remark2 = in_date.remark2
    local remark3 = in_date.remark3
    local remark4 = in_date.remark4
 
    -- step3 Ç yb!k÷S+ir™ex îO9e eQ“^USncLˆ
    local strCondition = " S_ITEM_CODE LIKE '%" .. item_code .. "%' AND S_BATCH_NO = '" .. batch_no .. "'"
    local strSetSQL_update = ""
    -- îO9eeQ“^USnc4Y
    if (product_date ~= nil and product_date ~= '') then strSetSQL_update = "D_PRODUCT = '" .. product_date .. "'," end
    if (level ~= nil and level ~= '') then strSetSQL_update = strSetSQL_update .. "S_LEVEL = '" .. level .. "'," end
    if (vendor ~= nil and vendor ~= '') then strSetSQL_update = strSetSQL_update .. "S_VENDOR = '" .. vendor .. "'," end
    if (strSetSQL_update ~= "") then
        strSetSQL_update = lua.trim_laster_char(strSetSQL_update)
        lua.Debug(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USnc4YSQL:", strSetSQL_update)
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Incoming_Info", strCondition, strSetSQL_update)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^nc4Y¶r`1Y%!" .. strRetInfo) end
    end
 
    -- îO9eeQ“^USncLˆ
    strSetSQL_update = ""
    if (product_date ~= nil and product_date ~= '') then strSetSQL_update = "D_PRODUCT = '" .. product_date .. "'," end
    if (item_state ~= nil and item_state ~= '') then
        strSetSQL_update = strSetSQL_update ..
            "S_ITEM_STATE = '" .. item_state .. "',"
    end
    if (wheel_type_rot ~= nil and wheel_type_rot ~= '') then
        strSetSQL_update = strSetSQL_update ..
            "S_WHEEL_TYPE_ROT = '" .. wheel_type_rot .. "',"
    end
    if (subpool ~= nil and subpool ~= '') then strSetSQL_update = strSetSQL_update .. "S_SUBPOOL = '" .. subpool .. "'," end
    if (storage_loc ~= nil and storage_loc ~= '') then
        strSetSQL_update = strSetSQL_update ..
            "S_STORAGE_LOC = '" .. storage_loc .. "',"
    end
    if (expire_date ~= nil and expire_date ~= '') then
        strSetSQL_update = strSetSQL_update ..
            "D_EXPIRE = '" .. expire_date .. "',"
    end
    if (strSetSQL_update ~= "") then
        strSetSQL_update = lua.trim_laster_char(strSetSQL_update)
        lua.Debug(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USncLˆSQL:", strSetSQL_update)
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Label_Crad", strCondition, strSetSQL_update)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USncLˆ¶r`1Y%!" .. strRetInfo) end
    end
end