--[[
|
编码:
|
名称:
|
作者:
|
日期: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
|