wsz
2025-06-20 19898bd66dec87b500b200d5d50961d0fb538ce5
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
--[[
    编码: JX-26-10
    名称: 机台-生成机台常量
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: ResetStationConst
 
    功能:
        -- 生成一个分类=【巨星机台】名为  "机台-A" 的常量, 值是一个机台属性的json
 
    更改记录:
 
--]]
wms_cntr= require( "wms_container" )
 
function ResetStationConst ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    local strCondition = "S_GROUP = '巨星机台'"
    nRet, strRetInfo = mobox.dbdeleteData( strLuaDEID, "WMS_Const", strCondition )
    if ( nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【常量】失败!  "..strRetInfo ) end 
 
    local n, data_objs
    local strCondition = ""
 
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Machine_Station", strCondition, "S_CODE" )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end
    if ( data_objs == '' ) then return  end
    
    local n
    local item_list = {}    -- 需要入库的货品
    local obj_attrs
    local station_info = {}
 
    -- 生成要入库的货品链表 item_list
    for n = 1, #data_objs do
        obj_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)    
        station_info = {
            factory = obj_attrs.S_FACTORY,
            code = obj_attrs.S_CODE,
            mac = obj_attrs.S_MAC_ADDRESS,
            loc_code = obj_attrs.S_LOC_CODE,
            entry_area_code = obj_attrs.S_ENTRY_AREA_CODE,
            entry_area_name = obj_attrs.S_ENTRY_AREA_NAME,
            storage_area = obj_attrs.S_STORAGE_AREA,                
            loc_order = lua.StrToNumber( obj_attrs.N_LOC_ORDER )
        }
 
        local const = m3.AllocObject( strLuaDEID, "WMS_Const")
        const.name = "机台"..'-'..obj_attrs.S_CODE
        const.value = lua.table2str( station_info )
        const.group = "巨星机台"
        const.sys = "N"
        const.note = "机台数据类生成"
        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, const)
        if (nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"创建WMS常量失败!"..strRetInfo) end     
    end  
    mobox.setInfo(strLuaDEID, "重置机台常量成功!!" )  
end