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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
ÿþ--[[
 x: GT-100-17
  Tðy: Í‘°e¡‹—{È~¹p'MO
 \O€: LZH
 eQãSýQpeÿRecalculateLoc
 ŸRý€ô‹f: ·ƒÖSûN¡R÷S0¹[hVx,͑°e¡‹—{È~¹p'MO
    “eQpencÿ                                                                                        
    {    
        "task_no": "xxx", USXbØvûN¡R÷S
        "type": "xxx", _8^{|‹W 1 ÖS'àe'ÿ•NÄ~'MO    ÿ 2 >e'    g'ÿ•NÄ~'MO,͑°e3u÷‹'MO    ÿ3 ÖSñmEm    gÿ•NÄ~'MO    ÿ 4 >eñmEm    gÿ•NÄ~'MO,͑°e3u÷‹'MO    ÿ
        "cntr_code": "xxx" 'irRFID
    }
 
    Yt;‘
    -- step1 ã‰g¥cãS O„v datajson ÂSpe
    -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
    -- step3 Í‘°e¡‹—{È~¹p'MO
 ØSôf†SòS:
 --]]
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
require("GT_InAndOutboundPolicies")
wms_task = require("wms_task")
function RecalculateLoc(strLuaDEID)
    local nRet, in_date, strRetInfo
    -- 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), '͑°e¡‹—{È~¹p'MOÂSpe:', in_date)
 
    -- step2 $R­e Å_kXy˜ /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local task_no = in_date.task_no
    local cntr_code = in_date.cntr_code
    local type = in_date.type
    if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R÷S Ný€:Nzz!") end
    if (type == nil or type == '') then lua.Error(strLuaDEID, debug.getinfo(1), "_8^{|‹W Ný€:Nzz!") end
 
    -- step3 ·ƒÖSûN¡Rù[aŒáOo`
    local task
    nRet, task = wms_task.GetInfo(strLuaDEID, task_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), task) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'task:', task)
 
    if (task.bs_state == 3) then
        lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡Rò]Œ[b!")
    elseif (task.bs_state == 4) then
        lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R_8^!")
    end
 
    -- ·ƒÖSûN¡RMOn„v0'MO0áOo`
    local localtion
    local strCondition
    if (tonumber(type) == 1 or tonumber(type) == 3) then
        strCondition = "S_CODE = '" .. task.start_loc_code .. "'"
    elseif (tonumber(type) == 2 or tonumber(type) == 4) then
        strCondition = "S_CODE = '" .. task.end_loc_code .. "'"
    end
    nRet, localtion = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO0áOo`1Y%! " .. localtion) end
 
    -- Ù~È~¹p'MOŒTù[”^„v…QYñmMO R•
    -- –:gub_8^„v÷S
    local strCode = 'YC' .. os.date("%y%m%d") .. '-'
    nRet, strCode = mobox.getSerialNumber("_8^x", strCode, 5)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '3u÷‹_8^x1Y%!' .. strCode) end
 
    -- ã‰•
    nRet, strRetInfo = wms.wms_UnlockByTask(strLuaDEID, task.code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_UnlockByTask 1Y%! " .. strRetInfo) end
 
    nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, localtion.code, wms_base.Get_nConst(strLuaDEID, "•{|‹W-vQƒ["),
        strCode, strCode, "_8^•š[")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo) end
 
    nRet, strRetInfo = OuterDeepPosition(strLuaDEID, localtion.row_group, localtion.code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '·ƒÖSù[”^„v…QYñmMO„v'MO!' .. strRetInfo) end
 
    nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, strRetInfo, wms_base.Get_nConst(strLuaDEID, "•{|‹W-vQƒ["),
        strCode, strCode, "_8^•š[")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo) end
 
    local loc_code
    if (tonumber(type) == 2 or tonumber(type) == 4) then
        -- 9hnc¹[hV·ƒÖS'ÁTáOo`
        local cg_detail
        nRet, cg_detail = wms_cntr.Get_Container_Goods(strLuaDEID, cntr_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), cg_detail) end
        if (cg_detail == nil or cg_detail == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), cg_detail)
        end
        nRet, cg_detail = m3.ObjAttrStrToLuaObj("CG_Detail", lua.table2str(cg_detail[1].attrs))
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ObjAttrStrToLuaObj1Y%! " .. cg_detail) end
 
        -- ·ƒÖSir™e{|‹W
        local item_type, material
        nRet, item_type, material = GT_Get_ItemType(strLuaDEID, cg_detail.item_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), item_type) end
 
        local param = {}
        param.item_code = cg_detail.item_code      -- ir™ex
        param.batch_no = cg_detail.batch_no        -- yb!k÷S
        param.condition = localtion.roadway     -- ïSeQ“^÷]S
        param.remark = false -- hƋ,false  Någ⋠Tyb!k„vYñmMO
        -- 9hncir™e{|‹W͑°e¡‹—{Ëz“^'MOÿîvMRËz“^êS    gö€™eŒT¢”N    ÿ
        if (item_type == 'ceňö€' or item_type == 'ö€™e' or item_type == ')Y6qö€') then
            nRet, loc_code = JL_StorageTactics(strLuaDEID, param)
        elseif (item_type == '¢”N') then
            nRet, loc_code = GS_StorageTactics(strLuaDEID, param)
        elseif (item_type == 'zzå]ň') then
            nRet, loc_code = Empty_StorageTactics(strLuaDEID,cntr_code,localtion.roadway)
        else
            lua.Error(strLuaDEID, debug.getinfo(1), "Ëz“^¡l    g" .. item_type .. "{|‹W„vir™e!")
        end
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), loc_code) end
        strCondition = "S_CODE = '" .. loc_code .. "'"
        nRet, localtion = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO0áOo`1Y%! " .. localtion) end
    end
    if (loc_code ~= nil) then
        task.end_loc_code = loc_code
        nRet, strRetInfo = wms_task.Update(strLuaDEID, task)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ôf°eûN¡RÈ~¹p1Y%!" .. strRetInfo) end
    else
        lua.Error(strLuaDEID, debug.getinfo(1), "÷]S“^X[ò]án!")
    end
    -- üb¥cԏÞV„vpenc
    local data = {
        end_loc_code = loc_code,
        task_no = task_no,
        roadway = localtion.roadway
    }
 
    mobox.returnValue(strLuaDEID, 1, lua.table2str(data))
end