lzh
2025-06-19 3a6436e0c88042c6ce8dca2fe8adb0109f0ad9e4
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
--[[
   编码: 
   名称: 
   作者:
   日期:2024-08-26
 
   函数: GenerateViewHTML
   功能:
 
   更改记录:
 
--]] json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function GenerateViewHTML(strLuaDEID)
    local nRet, strRetInfo
 
    --[[ 列明 ]]
 
    local taCol = {"", "已用", "剩余"}
    local strCol = ""
    for i = 1, #taCol do
        strCol = strCol ..
                     " <td  style='font-size: 16px;font-weight: 500;border-top: 2px dashed #fff;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;'>" ..
                     taCol[i] .. "</td>"
    end
    --[[ 行数据 ]]
    -- local tbRow = {{"片胶", 10, 20}, {"块胶", 10, 20}, {"粉胶", 10, 20}}
    --[[ 第一列向下合并行数 ]]
    -- local nRowSpan = #tbRow + 1
    -- local strRow = ""
    -- for i = 1, #tbRow do
    --     local tbR = tbRow[i]
    --     strRow = strRow .. '<tr>'
    --     for j = 1, #tbR do
    --         strRow = strRow ..
    --                      ' <td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..
    --                      tbR[j] .. '</td>'
    --     end
    --     strRow = strRow .. ' </tr>'
    -- end
 
    -- 获取所有机台编码
    local area
    local strCondition = "S_CODE LIKE '%CMB%' AND S_CODE NOT LIKE '%DP%'" -- 通过什么条件筛选机台
    nRet, area = m3.QueryDataObject(strLuaDEID, "Area", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "获取机台信息失败!" .. area)
    end
    if (area == "" or area == nil) then
        lua.Error(strLuaDEID, debug.getinfo(1), "根据条件" .. strCondition .. "未获取到机台信息!")
    end
    lua.Debug(strLuaDEID,debug.getinfo(1),"area!",area)
    local strTbsHtml = ""
    for i = 1, #area do
        local kjcondtion = "S_CODE LIKE '%RC%'"  -- 块胶判断条件
        local pjcondtion = "S_CODE LIKE '%PB%'" -- 块胶判断条件
        local fjcondtion = "S_CODE LIKE '%PM%'" -- 块胶判断条件
        -- 通过库区机台编码获取对应的货位使用情况
        local kjyy_count, kjwy_count, pjyy_count, pjwy_count, fjyy_count, fjwy_count
        -- 块胶数量查询
        local strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                                "' AND N_CURRENT_NUM <> 0 AND " .. kjcondtion
        nRet, kjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. kjyy_count)
        end
        strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                          "' AND N_CURRENT_NUM = 0 AND " .. kjcondtion
        nRet, kjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. kjwy_count)
        end
        -- 片胶数量查询
        strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                          "' AND N_CURRENT_NUM <> 0 AND " .. pjcondtion
        nRet, pjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. pjyy_count)
        end
        strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                          "' AND N_CURRENT_NUM = 0 AND " .. pjcondtion
        nRet, pjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. pjwy_count)
        end
        -- 粉胶数量查询
        strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                          "' AND N_CURRENT_NUM <> 0 AND " .. fjcondtion
        nRet, fjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. fjyy_count)
        end
        strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
                          "' AND N_CURRENT_NUM = 0 AND " .. fjcondtion
        nRet, fjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. fjwy_count)
        end
 
        strTbsHtml = strTbsHtml ..
                         '<div style="width: 14%;display: inline-block;margin: 5px;"><table style=" color: #fff;width: 100%;height: 100%;text-align: center;">' ..
                         '<tbody>' .. ' <tr>' ..
                         '<td rowspan="4" style="font-size: 16px;font-weight: 500;    border: 2px dashed #fff;">' ..
                         m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE .. '机台</td>' .. strCol .. '       </tr>' ..
 
                         '<tr> <td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">块胶</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..kjyy_count .. '</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..kjwy_count .. '</td> </tr>' ..
 
                         '<tr> <td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">片胶</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..pjyy_count .. '</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..pjwy_count .. '</td> </tr>' ..
                         '<tr> <td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">粉胶</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..
                         fjyy_count .. '</td>' ..
                         '<td  style="font-size: 16px;font-weight: 500;   border-bottom: 2px dashed #fff;   border-right: 2px dashed #fff;">' ..
                         fjwy_count .. '</td> </tr>' 
                         
                         .. '   </tbody>' .. '</table></div>'
    end
 
    -- local strTbsHtml = ""
    -- for i = 1, 30 do
 
    --     strTbsHtml = strTbsHtml ..
    --                      '<div style="width: 14%;display: inline-block;margin: 5px;"><table style=" color: #fff;width: 100%;height: 100%;text-align: center;">' ..
    --                      '<tbody>' .. ' <tr>' ..
    --                      '<td rowspan="4" style="font-size: 16px;font-weight: 500;    border: 2px dashed #fff;">' .. i ..
    --                      '号机台</td>' .. strCol .. '       </tr>' .. strRow .. '   </tbody>' .. '</table></div>'
 
    -- end
 
    local str_html = '<div style="height: 100%;text-align: center;margin: auto auto;">' .. strTbsHtml .. '</div>'
 
    local action = {{
        action_type = "chart",
        value = {
            graphicType = "html",
            title = {
                text = "17号机台",
                align = "left",
                color = "#fff",
                font = "微软雅黑",
                fontSize = 18
            },
            html = str_html
        }
    }}
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if (nRet ~= 0) then
        Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction)
    end
end