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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
ÿþ--[[
    x: WMS-04-50
     Tðy: 'MO-ybϑRú^'MO
    \O€ÿHAN  
    åegÿ2024-5-18
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
    
    ýQpeÿ CreateAreaLocation
 
    ŸRý€:
        -- (WRú^MRHQ Rd–cš[“^:S̑@b    g'MOÿàVdkgbLˆÙ*NŸRý€‰\Ã_    ÿ
        -- (Wy˜îvž[½eRgÇÙ*N‹NöNïSåNybϑRú^N›N'MO ÿyr+R/f(WËz“^y˜îv-Nyr+R    g(u
        -- ïSåNN!kŠbN*NËz“^-N„v@b    g'MOýRú^ ÿxïSåN9hncy˜îv‰BlŒte
        -- yr+R/fù[    gñmMO„vËz“^-N ÿÇå‹,gý€ë_Œ[bÓN“^“^MO„v¾‹n
 
        Ç9_FhúQ°s„vꁚ[INLub— ÿ·ƒÖSËz“^“^MORËYS@b—‰„váOo` ÿÇÙ›NáOo`egybϑRú^'MO(“^MO)
    
    ôf9e°‹U_:
  
--]]
wms_wh = require( "wms_wh" )
 
local nRowNo             -- ’c÷S
local nRowGroup          -- (uŽNñmMO'MO
local max_col, max_layer, nRowSegLen, nColSegLen, nLayerSegLen, nRowGroupSegLen
local strRoadWayNo      -- ÷]S÷S
local capacity = 1
 
-- bIsLeftRow Rú^„v’c/f&T(W÷]Sæ]¹
-- nRowCount Rú^„v’cpeϑ
-- nRoadWayNo ÷]S÷S
local function create_loaction( strLuaDEID, area, bIsLeftRow, nRowCount, nRoadWayNo )
    local nRow
    local nRet, strRetInfo
    local strRowNo, strColNo, strLayerNo
 
    for nRow = 1, nRowCount do
        nRowNo = nRowNo + 1
        strRowNo = tostring( nRowNo )
        strRowNo = lua.strFill(strRowNo,nRowSegLen,"0")
        for nCol = 1, max_col do
            strColNo = tostring( nCol )
            strColNo = lua.strFill(strColNo,nColSegLen,"0")
            for nLayer = 1, max_layer do
                strLayerNo = tostring( nLayer )
                strLayerNo = lua.strFill(strLayerNo,nLayerSegLen,"0")
 
                local location = m3.AllocObject(strLuaDEID,"Location")
                location.wh_code = area.wh_code
                location.area_code = area.code
                location.code = area.code..strRoadWayNo..'-'..strRowNo.."-"..strColNo.."-"..strLayerNo
                location.roadway = nRoadWayNo
                location.row = nRowNo
                location.col = nCol
                location.layer = nLayer
                location.capacity = capacity
                location.enable = 'Y'
                location.deep = nRowCount
                if ( nRowCount > 1 ) then
                    location.loc_type = 4       -- ñmMO
                    if ( bIsLeftRow ) then      -- ÷]Sæ]¹„v’c
                        location.pos = nRowCount - nRow + 1
                    else
                        location.pos = nRow
                    end
                    location.row_group = nRowGroup
                end
                nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, location )
                if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), 'Rú^0'MO0ù[aŒ1Y%!'..strRetInfo ) end
            end
        end
    end    
 
    -- ‚Yœg/fñmMO'MO—‰ç~í~Rú^ Location_Group
    if ( nRowCount <= 1 ) then return end
    local strRowGroupNo = tostring( nRowGroup )
    strRowGroupNo = lua.strFill(strRowGroupNo,nRowGroupSegLen,"0")
 
    for nCol = 1, max_col do
        strColNo = tostring( nCol )
        strColNo = lua.strFill(strColNo,nColSegLen,"0")        
        for nLayer = 1, max_layer do
            strLayerNo = tostring( nLayer )
            strLayerNo = lua.strFill(strLayerNo,nLayerSegLen,"0")            
            local location_group = m3.AllocObject(strLuaDEID,"Location_Group")
            location_group.wh_code = area.wh_code
            location_group.area_code = area.code
            location_group.code = "LG-"..strRowGroupNo.."."..strColNo.."."..strLayerNo
            location_group.roadway = nRoadWayNo
            location_group.row_group = nRowGroup
            location_group.col = nCol
            location_group.layer = nLayer
            location_group.capacity = nRowCount*capacity           -- 'MOÄ~„v¹[ϑ
            location_group.deep = nRowCount
            nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, location_group )
            if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), 'Rú^0'MOÄ~0ù[aŒ1Y%!'..strRetInfo ) end
        end
    end    
end
 
local function get_row_str( nCount )
    local n
    local str_row = ''
 
    for n = 1, nCount do
        str_row = str_row..(n+nRowNo)..","
    end
    lua.trim_laster_char( str_row )
    return str_row
end
 
function CreateAreaLocation ( strLuaDEID ) 
    local nRet, strRetInfo
 
    -- ·ƒÖS“eQLub—-N„v^\'`
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "AREA_CODE","LOC_TYPE","LOC_CAPACITY","ROADWAY_COUNT","LEFT_ROW",
                                                    "RIGHT_ROW","MAX_COL","MAX_LAYER" )  
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! "..strRetInfo ) end 
 
    local obj_attrs = json.decode( strRetInfo ) 
    local area_code = obj_attrs[1].value                        -- “^:Sx        
    local loc_type = obj_attrs[2].value                         -- “^MO{|‹W         
    capacity = lua.StrToNumber( obj_attrs[3].value )          -- 'MO¹[ϑ
 
    local roadway_count = lua.StrToNumber( obj_attrs[4].value )     -- ÷]Speϑ
    local left_row = lua.StrToNumber( obj_attrs[5].value )          -- æ]¹’cpe
    local right_row = lua.StrToNumber( obj_attrs[6].value )         -- óS¹’cpe
    max_col = lua.StrToNumber( obj_attrs[7].value )           -- g'YRpe
    max_layer = lua.StrToNumber( obj_attrs[8].value )         -- g'YB\pe       
 
    -- $R­e“^:S/f&Tò]Ï~X[(W
    if ( area_code == nil or  area_code == '') then
        lua.Error( strLuaDEID, debug.getinfo(1), "“^:Sx Ný€:Nzz! "..strRetInfo ) 
    end 
 
    nRet, area = wms_wh.GetAreaInfo( area_code )
    if (nRet ~= 0) then 
        strErr = "ÎN…QX[·ƒÖSx'"..area_code.."'„v“^:SáOo`1Y%!, “^:S NX[(W!"
        lua.Error( strLuaDEID, debug.getinfo(1), strErr )
    end
    -- $R­e÷]Speϑ
    if ( roadway_count <= 0 ) then
        lua.Error( strLuaDEID, debug.getinfo(1), "÷]SpeϑÅ_{˜'YŽN0" )
    end
    -- $R­e'MO¹[ϑ
    if ( capacity <= 0 ) then
        lua.Error( strLuaDEID, debug.getinfo(1), "'MO¹[ϑÅ_{˜'YŽN0" )
    end    
 
    --  Rd–“^:S-N„v@b    g'MOš[IN
    local strCondition = "S_AREA_CODE = '"..area_code.."'"
    nRet, strRetInfo = mobox.dbdeleteData( strLuaDEID, "Location", strCondition )
    if ( nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), " Rd–0'MO0áOo`1Y%!  "..strRetInfo ) end  
 
    -- 9hncN*N÷]SRú^÷]Sæ]óS$N¹„v'MO
    local n
    local nRow, nCol, nLayer
 
    nRowNo = 0              -- ’c÷S
    nRowGroup = 1           -- (uŽNñmMO'MO
 
    -- nxš[÷]S ÿ’c ÿR ÿB\xµk„vW[&{2N•¦^,(uŽNub'MOx
 
    local strBuf
    strBuf = tostring( roadway_count )
    nRoadWaySegLen = #strBuf
    local max_row = ( left_row + right_row )*roadway_count
    strBuf = tostring( max_row )
    nRowSegLen = #strBuf    
    strBuf = tostring( max_col )
    nColSegLen = #strBuf    
    strBuf = tostring( max_layer )
    nLayerSegLen = #strBuf   
    
    local max_row_group = 2*roadway_count
    strBuf = tostring( max_row_group )
    nRowGroupSegLen = #strBuf      
 
    local left_row_group, right_row_group
    local left_row_str, right_row_str
    for n = 1, roadway_count do
        strRoadWayNo = tostring( n )
        strRoadWayNo = lua.strFill(strRoadWayNo,nRoadWaySegLen,"0")
        -- Rú^æ]¹’c
        left_row_group = nRowGroup
        left_row_str = get_row_str( left_row )
        create_loaction( strLuaDEID, area, true, left_row, n )
        nRowGroup = nRowGroup + 1
        -- Rú^óS¹’c
        right_row_group = nRowGroup
        right_row_str = get_row_str( left_row )
        create_loaction( strLuaDEID, area, false, right_row, n )
        nRowGroup = nRowGroup + 1
 
        -- Rú^÷]S¡{tù[aŒ
        local roadway = m3.AllocObject(strLuaDEID,"Roadway")
        roadway.wh_code = area.wh_code
        roadway.area_code = area.code
        roadway.roadway = n
        roadway.left_row = left_row_str
        roadway.left_row_group = left_row_group
        roadway.left_deep = left_row
        roadway.right_row = right_row_str
        roadway.right_row_group = right_row_group
        roadway.right_deep = right_row
 
        nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, roadway )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), 'Rú^0÷]S0ù[aŒ1Y%!'..strRetInfo ) end        
    end
 
end