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
ÿþ--[[
    x: GT-05-01
     Tðy: Åˆ±{!hŒš
    \O€ÿLZH
    åegÿ2024-5-7
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ BeforeDataObjCreate
 
    ŸRý€:
        -- ·ƒÖS0RPDAkbx„vagxAm4l÷S ÿågâ‹îvƉaSáOo` ÿ$R­eå‹îvƉaSáOo`/f&Tò]!hŒšÇ ÿ/f&TŒšÁ‹W[µk:NYR¥b•
        -- ÇîvƉaSáOo`-N„v'US÷S0Ǒ-¢‹US÷S0Ǒ-¢‹USLˆ÷SŒTň±{å]US„v‘¶r`$R­eå‹îvƉaS N„vir™e/f&TX[(Wň±{å]US-N ÿ NX[(W¥b•
 
    ôf9e°‹U_:
        V2.0  HAN 2024/5/11 Ó~„gŒte
        V2.1 LZH 2024/8/9 penc!j‹WÓ~„gØS¨RŒte
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
wms_base = require( "wms_base" )
function BeforeDataObjCreate(strLuaDEID)
    local nRet, strRetInfo,label_card
 
    -- ·ƒÖSS_MRRú^„vpencù[aŒ^\'`
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_SERIAL_NO", "S_STATION", "S_PDA_NO")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¹eÕlGetSysDataJsonúQ•") end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local serial_no = obj_attrs[1].value -- Am4l÷S
    local station_no = obj_attrs[2].value
    local pda_no = obj_attrs[3].value
    if (station_no == nil or station_no == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "÷‹“eQå]MO!")
    end
 
    --·ƒÖSîvƉaSáOo`
    nRet, label_card = m3.GetDataObjectByKey(strLuaDEID, "GT_Label_Crad", "S_SERIAL_NO", serial_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSîvƉaSáOo`1Y%ÿ" .. label_card) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'label_card', label_card)
 
    -- $R­eå‹agxáOo`/f&Tò]!hŒšÇ ÿ/f&TŒšÁ‹W[µk:N Y(—‰ŒšÁ‹) R¥b•
    if (label_card.is_validate == "Y" and label_card.verify_result ~= "OK") then
        lua.Error(strLuaDEID, debug.getinfo(1), "îvƉaS*gZPir™exŒšÁ‹ÿ")
    end
    
    -- V2.2 $R­eň±{!hŒš_sQ/f&T_/T,*g_/TRÐc:y
    strRetInfo = wms_base.Get_sConst(strLuaDEID, "sO-ň±{!hŒš_sQ")
    if(strRetInfo == 'N')then
        lua.Error(strLuaDEID, debug.getinfo(1), "ň±{!hŒšŸRý€*g_/T!")
    end
 
    -- V2.2 $R­eAm4l÷S/f&TÑ~š[¹[hV,Ñ~š[R¥b•
    local strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
    nRet, str = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    if (nRet == 2) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS¹[hV'ÁTfÆ~1Y%!" .. str) end
    if (nRet == 0 and str ~= nil and str ~= '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "Am4l÷Sò]Ñ~š[¹[hV!")
    end
 
    --$R­e(WPDAÑ~š[„vå]MO/f&TX[(W S_MRÿîvƉaS    ÿAm4l÷S „vň±{å]US
    local strCondition = "S_ORDER_NO = '" ..
        label_card.order_no .. "' and S_STATE = '/T(u' and S_STATION = '" .. station_no .. "'"
    nRet, strRetInfo = mobox.existThisData(strLuaDEID, "GT_Packing_Order", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "existThisData1Y%! " .. strRetInfo) end
    if (strRetInfo == 'no') then
        lua.Error(strLuaDEID, debug.getinfo(1), "å]MO'" .. station_no .. "' NX[(WeQ“^US÷S:N = '" .. label_card.order_no .. "'„vň±{å]US")
    end
 
    -- $R­e/f&TX[(Wå‹Am4l÷S„v!hŒš°‹U_ÿ2–bk͑ Y    ÿ
    strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
    nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "GT_Packing_Check", strCondition )
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS!hŒš°‹U_1Y%!" .. strRetInfo) end
    if(tonumber(strRetInfo) >= 1)then
        lua.Error(strLuaDEID, debug.getinfo(1), "Am4l÷S"..serial_no.."ò]X[(W!hŒš!")
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
 
    -- ¾‹náOo`
    local attr_value = {}
    attr_value[1] = lua.KeyValueObj("S_DELIVERY_NO", label_card.delivery_no)
    attr_value[2] = lua.KeyValueObj("S_DELIVERY_ROW_NO", label_card.delivery_row_no)
    attr_value[3] = lua.KeyValueObj("S_ITEM_CODE", label_card.item_code)
    attr_value[4] = lua.KeyValueObj("S_ITEM_NAME", label_card.item_name)
 
    nRet, strRetInfo = mobox.setCurEditDataObjAttr(strLuaDEID, lua.table2str(attr_value))
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "¾‹n0ûN¡R0áOo`1Y%!  " .. strRetInfo) end
end