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
65
66
67
68
69
70
71
72
73
74
75
76
77
--[[
    编码: WMS-28-03
    名称: 盘点单-创建后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AfterDataObjCreate
 
    功能:
        -- 把盘点单里的容器的货位从新刷新一下
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function AfterDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_COUNT_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local count_code = lua.Get_StrAttrValue( obj_attrs[1].value )
    if  ( count_code == '' ) then return end
 
   -- 获取容器所在的货位
   local strCondition, strClsID
   local strOrder = ''
   strCondition = "S_CNTR_CODE IN ( Select S_CNTR_CODE From TN_CP_Count_Container Where "
   strCondition = strCondition.." S_COUNT_NO ='"..count_code.."')"
 
   -- 多页查询
   nRet, strRetInfo = mobox.queryDataObjAttr2( strLuaDEID, "Loc_Container", strCondition, strOrder, 100, "S_LOC_CODE","S_CNTR_CODE" )
   if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2: "..strRetInfo) end  
   if  ( strRetInfo == '' ) then return end
   local success
   local queryInfo
   success, queryInfo = pcall( json.decode, strRetInfo )
   if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2 返回结果啊非法的JSON格式!" ) end
 
   local queryID = queryInfo.queryID
   local nPageCount = queryInfo.pageCount
   local nPage = 1
   local dataSet = queryInfo.dataSet       -- 查询出来的数据集
   local strSetAttr, loc_code, cntr_code
   local loc
   while (nPage <= nPageCount) do
 
       for n = 1, #dataSet do
           loc_code = dataSet[n].attrs[1].value
           cntr_code = dataSet[n].attrs[2].value
 
           nRet, loc = wms_wh.GetLocInfo( loc_code )
           if ( nRet == 0 )  then 
               strCondition = "S_CP_NO = '"..count_plan.cp_no.."' AND S_CNTR_CODE = '"..cntr_code.."'"
               strSetAttr = "S_LOC_CODE = '"..loc.code.."', S_WH_CODE = '"..loc.wh_code.."'"..
                            ", S_AREA_CODE = '"..loc.area_code.."', N_AISLE = "..loc.aisle..",S_AISLE_CODE = '"..loc.aisle_code.."'"..
                            ", N_ROW = "..loc.row..", N_COL = "..loc.col..", N_LAYER = "..loc.layer
 
               nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "CP_Count_Container", strCondition, strSetAttr )
               if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition失败"..strRetInfo ) end   
           end
       end        
 
       nPage = nPage + 1
       if ( nPage <= nPageCount ) then
           -- 取下一页
           nRet, strRetInfo = mobox.queryDataObjAttr2( queryID, nPage)
           if ( nRet ~= 0 ) then
               lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2失败! nPage="..nPage.."  "..strRetInfo )
           end 
           queryInfo = json.decode(strRetInfo) 
           dataSet = queryInfo.dataSet              
       end
   end
end