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
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
213
214
215
--[[
   编码: AGV-MOBOX-004
   名称:
   作者:
   日期:2025-05-13
 
   函数: GenerateViewHTML
   功能:
 
   更改记录:
 
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3    = require("oi_base_mobox")
 
function GenerateViewHTML(strLuaDEID)
    local nRet, strRetInfo
    local autoplay = false
    local strHtmlTitle = "";
    local strHtmlRow = "";
    --[[ 获取样式 ]]
    local strHtmlStyle = GetHtmlStyle();
    --[[    列明 ]]
    local tabTitleList = { "库区", "今日入库数量", "今日出库数量", "今日搬运数量" }
    -- 平库库区编码
    local area_code_list = { 'LK', 'TH', 'LZB' }
 
    --[[ 组织列名 ]]
    --[[ class 处理样式 这里 组成(table-col' .. i .. ') table-col1,table-col2,table-col3 ]]
    for i = 1, #tabTitleList do
        strHtmlTitle = strHtmlTitle .. '<div class="table-col' .. i .. '">' .. tabTitleList[i] .. '</div>'
    end
 
    -- 获取当前日期
    local current_time = os.time()
    local current_date = os.date("*t", current_time)
    local current_month = current_date.month
    local current_day = current_date.day
 
    -- 获取执行中的任务数据
    local tabDataList = {}
    for i = 1, #area_code_list do
        -- 根据月份和天数获取入库任务数量
        local rk_count, ck_count, by_count
        local strCondtion = "EXTRACT(MONTH FROM T_CREATE) = " ..
            current_month ..
            " AND EXTRACT(DAY FROM T_CREATE) = " ..
            current_day .. " AND S_START_AREA = '" .. area_code_list[i] .. "'"
        nRet, rk_count = mobox.getDataObjCount(strLuaDEID, "Task", strCondtion)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取任务失败!" .. rk_count) end
 
        -- 根据月份和天数获取出库任务数量
        strCondtion = "EXTRACT(MONTH FROM T_CREATE) = " ..
            current_month ..
            " AND EXTRACT(DAY FROM T_CREATE) = " .. current_day .. " AND S_END_AREA = '" .. area_code_list[i] .. "'"
        nRet, ck_count = mobox.getDataObjCount(strLuaDEID, "Task", strCondtion)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取任务失败!" .. ck_count) end
 
        -- 根据月份和天数获取搬运任务数量
        strCondtion = "EXTRACT(MONTH FROM T_CREATE) = " ..
            current_month ..
            " AND EXTRACT(DAY FROM T_CREATE) = " ..
            current_day .. " AND S_END_AREA <> '" .. area_code_list[i] ..
            "' AND S_START_AREA <> '" .. area_code_list[i] .. "'"
        nRet, by_count = mobox.getDataObjCount(strLuaDEID, "Task", strCondtion)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取任务失败!" .. by_count) end
 
        tabDataList[i] = {
            code = area_code_list[i],
            rk_qty = rk_count,
            ck_qty = ck_count,
            by_qty = by_count
        }
    end
 
 
    --[[ 数据 ]]
    -- local tabDataList = { {
    --     code = "OP101120-0120",
    --     rk_qty = "K2-122-131",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- }, {
    --     code = "OP101120-0121",
    --     rk_qty = "K2-122-132",
    --     ck_qty = "K2-122-136",
    --     by_qty = "#ff5722"
    -- }, {
    --     code = "OP101120-0122",
    --     rk_qty = "K2-122-133",
    --     ck_qty = "K2-122-137",
    --     by_qty = "#ffc107"
    -- }, {
    --     code = "OP101120-0123",
    --     rk_qty = "K2-122-134",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- }, {
    --     code = "OP101120-0124",
    --     rk_qty = "K2-122-134",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- }, {
    --     code = "OP101120-0125",
    --     rk_qty = "K2-122-134",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- }, {
    --     code = "OP101120-0126",
    --     rk_qty = "K2-122-134",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- }, {
    --     code = "OP101120-0127",
    --     rk_qty = "K2-122-134",
    --     ck_qty = "K2-122-135",
    --     by_qty = "#2196F3"
    -- } }
 
    if (#tabDataList > 4) then
        autoplay = true
    end
 
    --[[ 组织行数据html ]]
    for i = 1, #tabDataList do
        strHtmlRow = strHtmlRow .. '<div class="swiper-slide"><div class="table-row-data">' ..
            '<div class="table-col1">' ..
            tabDataList[i].code .. '</div>' .. '<div class="table-col2">' .. tabDataList[i].rk_qty ..
            '</div>' ..
            '<div class="table-col3">' ..
            tabDataList[i].ck_qty ..
            '</div>' .. '<div class="table-col4">' .. tabDataList[i].by_qty .. '</div>' .. '</div></div>'
    end
 
    --[[ 总html ]]
    local strHtml = ' <div class="AGVtable4">' .. '<div class="table-head">' .. strHtmlTitle .. '</div>' ..
        '<div class="table-body"  style="overflow: hidden;"> <div class="swiper-container agvtable4"><div class="swiper-wrapper">' ..
        strHtmlRow .. '</div></div></div>' .. '</div>'
 
    local action = {}
    action[1] = {
        action_type = "chart",
        value = {
            graphicType = "html",
            title = {
                text = "",
                align = "left",
                color = "#fff",
                font = "微软雅黑",
                fontSize = 18
            },
            swiper = {
                --[[ 容器名称不能重复 不能为空 swiper-container class 需要指定 ]]
                containerName = "agvtable4",
                --[[ 强制Swiper的宽度(px),"undefined" 或  整数, 当你的Swiper在隐藏状态下初始化时用得上。这个参数会使自适应失效。可设置为undefined使这个参数无效。  ]]
                width = "undefined",
                --[[ 强制Swiper的高度(px),当你的Swiper在隐藏状态下初始化时且切换方向为垂直才用得上。这个参数会使自适应失效。 ]]
                height = 220,
                --[[ 排列方向  vertical , horizontal ]]
                direction = "vertical",
                --[[  切换速度,即slider自动滑动开始到结束的时间(单位ms) ]]
                speed = 1000,
                --[[  loop 模式如果与 slidesPerView: 'auto' 一起使用,需要设置 loopedSlides 指定要循环(重复)的幻灯片数量。 ]]
                loop = true,
                --[[  设置slider容器能够同时显示的slides数量,整数或auto ]]
                slidesPerView = 'auto',
                --[[  在slide之间设置距离(单位px)。 ]]
                spaceBetween = 2,
                --[[  默认情况下Swiper 每次滑动时只滑动一个Slide,并且会自动贴合Wrapper。开启自由模式后,Swiper 会根据惯性滑动可能不止一格且不会贴合。 ]]
                freeMode = true,
                --[[ 设定slide与左边框的预设偏移量(单位px)。 垂直就行与上方距离 ]]
                slidesOffsetBefore = 0,
                --[[  设定slide与右边框的预设偏移量(单位px)。 垂直就行与下方距离 ]]
                slidesOffsetAfter = 0,
                --[[是否自动播放,true 需要指定 autoplayDelay ]]
                autoplay = autoplay,
                --[[ 播放间隔时间,单位ms  ]]
                autoplayDelay = 500
            },
            html = strHtmlStyle .. strHtml
        }
    }
 
    -- Debug( strLuaDEID, debug.getinfo(1), "action! ", action )
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, json.encode(action))
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo)
    end
end
 
function GetHtmlStyle()
    return
        '<style>' ..
        '.AGVtable4 {' .. '    border: 2px solid #fff;' .. '    width: 100%;' .. '    height: 100%;' .. '}' ..
        '.table-head {' .. '    border-bottom: 2px solid #fff;    color: #fff;' .. '}' .. '.table-head>div {' ..
        '    text-align: center;' .. '    display: inline-block;' .. '    padding: 5px 0px;' ..
        '    font-size: 17px;' ..
        '    font-weight: 600;' .. '}' .. '.AGVtable4 .table-head .table-col1 {' .. '    width: 25%;' ..
        '    border-right: 2px solid;' .. '}' .. '.AGVtable4 .table-head .table-col2 {' .. '    width: 25%;' ..
        '    border-right: 2px solid;' ..
        '}' ..
        '.AGVtable4 .table-head .table-col3 {' ..
        '    width: 25%;' ..
        '    border-right: 2px solid;' .. '}' .. '.AGVtable4 .table-head .table-col4 {' .. '    width: 25%;' .. '}' ..
        '.AGVtable4 .table3 .table-body .table-row-data{    margin-top: 10px;} .table-body .table-row-data>div {' ..
        '    text-align: center;' .. '    display: inline-block;' .. '    padding: 5px 0px;' .. '    color: #fff;' ..
        '}' ..
        '.AGVtable4 .table-row-data .table-col1 {' ..
        '    width: 25%;' .. '}' .. '.AGVtable4 .table-row-data .table-col2 {' .. '    width: 25%;' .. '}' ..
        '.AGVtable4 .table-row-data .table-col3 {' ..
        '    width: 25%;' .. '}' .. '.AGVtable4 .table-row-data .table-col4 {' .. '    width: 25%;' .. '}' .. '</style>'
end