fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
--[[
    编码: WMS-80-10
    名称: 机台-生成设备常量
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: ResetDevConst
 
    功能:
        -- 生成一个分类=【巨星机台】名为  "机台-A" 的常量, 值是一个机台属性的json
 
    更改记录:
 
--]]
wms_base = require ("wms_base")
 
function ResetDevConst ( 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, area_code
 
    nRet, area_code = wms_base.Get_sConst2( strLuaDEID, "料箱库存储区")
    if ( nRet ~= 0 ) then
        lua.Stop( strLuaDEID, "系统无法获取常量'料箱库存储区'")
        return
    end 
 
    -- 生成库区堆垛机设备及巷道
    local strCondition = "S_AREA_CODE = '"..area_code.."' AND N_TYPE = 5"
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Equipment", 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 obj_attrs
    local dev_info = {}
    local dev = {}
    -- 生成要入库的货品链表 item_list
    for n = 1, #data_objs do
        obj_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)    
        dev_info = {
            dev_no = obj_attrs.S_CODE,
            cntr_num = 0,                                  -- 入库口接驳位料箱数量
            aisle = lua.StrToNumber( obj_attrs.N_AISLE)     -- 巷道
        }
        table.insert( dev, dev_info )
    end  
 
    local const = m3.AllocObject( strLuaDEID, "WMS_Const")
    const.name = "Area-"..area_code.."-StackerCrane"
    const.value = lua.table2str( dev )
    const.group = "WMS-Basis"
    const.sys = "N"
    const.note = "程序生成"
    nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, const)
    if (nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"创建WMS常量失败!"..strRetInfo) end       
    mobox.setInfo(strLuaDEID, "重置设备常量成功!!" )  
end