sgj
2026-03-06 bd3c4b90882fc29711a5e73f4929db2da3e22cb6
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
var colors = {};
var map;
var type = "0";
var county = "all";
var breedChart = null;
var foodNumPerColors = ["0, 255, 255", "50, 255, 50", "255, 215, 0", "255, 69, 0", "0, 191, 255", "30, 144, 255", "255, 20, 147", "255, 105, 180", "0, 255, 127", "255, 165, 0", "255, 218, 185", "255, 255, 0", "0, 250, 155", "255, 99, 71"];
//var switch2AreaNode2;
 
 
let iframe = document.getElementById("gisFrame");
 
// ============ 接收iframe消息 ============
window.addEventListener("message", function (event) {
    // 生产环境建议校验 event.origin
    const data = event.data;
 
    if (data && data.type === "CLICK_BUILDING") {
        // alert(`点击了仓库 ${data.data.uid}`);
        renderDepotMess(data.data.uid);
    }
});
 
$(function () {
    //初始化时间
    initTime();
    initDicSlogan();
 
    //初始化左侧图表
    pieChartLoad(
        [
            {value: "0", name: '伊宁市'},
            {value: "0", name: '奎屯市'},
            {value: "0", name: '霍尔果斯市'},
            {value: "0", name: '伊宁县'},
            {value: "0", name: '察布查尔锡伯自治县'},
            {value: "0", name: '霍城县'},
            {value: "0", name: '巩留县'},
            {value: "0", name: '新源县'},
            {value: "0", name: '昭苏县'},
            {value: "0", name: '特克斯县'},
            {value: "0", name: '尼勒克县'}
        ],
        'breedChart'
    );
    window.onresize = function (e) {
        if (breedChart) {
            breedChart.resize();
        }
    }
 
    //渲染部门
    renderList();
 
    renderNum();
    //定位到新疆省
    setTimeout(function () {
        positioning("650000");
    }, 2000);
 
    $('.sup-menu-title').click(function () {
        var kai = $(this).parent(".sup-menu-group")
        if (kai.hasClass('menu-group')) {
            kai.removeClass('menu-group')
        } else {
            kai.addClass('menu-group')
        }
    });
    $('.sup-menu-h').click(function () {
        var kai2 = $(this).parents(".sup-menu-ul")
        if (kai2.hasClass('menu-h')) {
            kai2.removeClass('menu-h')
        } else {
            kai2.addClass('menu-h')
        }
    });
 
    // 初始化WebSocket
    // initWS(companyId, bizType, bizTag, userId);
 
    renderDeptMess(defaultDeptId);
});
 
function renderDeptMess(deptId) {
    for (let i = 0; i < deptList.length; i++) {
        if( deptId == deptList[i].deptId){
            let htmlMess=` 
                    <div class="panel-title">库点信息</div>
                    <div class="right-topInfo-address">
                        <i class="i-icon32"><img th:src="@{/img/web/group/icon-address.png}" alt=""></i>
                        <span >${deptList[i].county}</span>
                    </div>
                    <div class="panel-content">
                        <h2 class="right-topInfo-kd-h" >${deptList[i].deptName}</h2>
                        <div class="right-topInfo-kd">
                            <div class="right-topInfo-kd-item">
                                <h3>当日入库单数(个)</h3>
                                <p >${deptList[i].inNum}</p>
                            </div>
                            <div class="right-topInfo-kd-item">
                                <h3>当日出库单数(个)</h3>
                                <p >${deptList[i].outNum}</p>
                            </div>
                        </div>
                        <ul class="right-topInfo-kd-list right-topInfo-jg">
                            <li>
                                <p >${deptList[i].depotNumber}</p>
                                <h3>仓库数(个)</h3>
                            </li>
                            <li>
                                <p >${deptList[i].depotBankNumber}</p>
                                <h3>质押仓数(个)</h3>
                            </li>
                            <li>
                                <p >${deptList[i].storageNum}</p>
                                <h3>库存数(吨)</h3>
                            </li>
                        </ul>
                    </div>`;
            $("#areaInformation").html(htmlMess);
        }
    }
}
 
 
function renderDepotMess(depotId) {
    for (let i = 0; i < depotList.length; i++) {
        if( depotId == depotList[i].depotId){
 
            let htmlMess=` 
                    <div class="panel-title">库点信息</div>
                    <div class="right-topInfo-address">
                        <i class="i-icon32"><img th:src="@{/img/web/group/icon-address.png}" alt=""></i>
                        <span>${depotList[i].county}</span>
                    </div>
                    <div class="panel-content">
                        <h2 class="right-topInfo-kd-h">${depotList[i].deptName}</h2>
                        <div class="modeling-left-topInfo-kd">
                            <div class="modeling-left-topInfo-ck">
                                <h1>${depotList[i].depotName}</h1>
                            </div>
                        </div>
                        <ul class="modeling-left-topInfo-kd-list right-topInfo-jg">
                            <li>
                                <p>${depotList[i].storageNum}</p>
                                <h3>库存数(吨)</h3>
                            </li>
                        </ul>
                    </div>
        `;
            $("#areaInformation").html(htmlMess);
        }
    }
 
}
 
function socketOnMessage(pocket) {
    //console.log(pocket);
    if (pocket.bizId == "slogan") {
        var data = pocket.data;
        dicSlogan = data;
        initDicSlogan();
    }
}
 
// 刷新时间
function positioning(code) {
 
    var kai = $("#prov");
    if (kai.hasClass('menu-group')) {
        kai.removeClass('menu-group')
    } else {
        kai.addClass('menu-group')
    }
 
    // renderAreas(code);
}
 
// 刷新时间
function initTime() {
    setInterval(function () {
        $("#navBarDate").html(formatDate('mm月dd日', new Date()));
        $("#navBarTime").html(formatDate('HH:MM:SS', new Date()));
        $("#navBarWeek").html(getWeekDate());
    }, 1000);
}
 
 
//库区点击事件
function clickDept(deptid) {
    // 方案一:通知iframe切换库区
    if (iframe.contentWindow) {
        iframe.contentWindow.postMessage(
            {
                type: "CHANGE_AREA",
                data: {uid: deptid},
            },
            "*", // 生产环境建议替换为具体域名
        );
    }
    // 方案二:直接修改src(会重新加载页面)
    // iframe.src = `http://172.67.157.132:5000?uid=${uid}`;
    //切换库区的库点信息
    renderDeptMess(deptid);
}
 
/**
 * 渲染库区列表
 */
function renderList() {
    if (areaList) {
        var html = "";
        var childs = [];
        var childsItem = [];
        var areas = [];
        for (var i = 0; i < areaList.length; i++) {
            html += "<div style=\"width: 340px; overflow: hidden\">" +
                "<div id='prov' class=\"sup-menu-group menu-group\">" +
                "<div class=\"sup-menu-title\">" +
                "<i class=\"i-icon fl\"><img src=\"/img/web/group/icon-sj.png\"/></i>" +
                "<a href=\"###\" onclick=\"clickDept('" + areaList[i].code + "')\">" +
                // "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/c-i2.png\"/></span>" +
                (areaList[i].name ? areaList[i].name : "") +
                "</a>" +
                "</div>";
            if (areaList[i].children && areaList[i].children.length > 0) {
                childs = areaList[i].children;
                for (var j = 0; j < childs.length; j++) {
                    //默认关闭库区
                    // html += "<ul class=\"sup-menu-ul  menu-h\">" +
                    //默认展开库区
                    html += "<ul class=\"sup-menu-ul  \">" +
                        "<li>" +
                        "<div class=\"sup-menu-h\">" +
                        "<i class=\"i-icon fl\"><img src=\"/img/web/group/icon-sj.png\"/></i>" +
                        "<a href=\"###\" onclick=\"clickDept('" + childs[j].code + "')\">" +
                        // "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/c-i2.png\"/></span>" +
                        (childs[j].name ? childs[j].name : "") +
                        "</a>" +
                        "</div>";
                    if (childs[j].children && childs[j].children.length > 0) {
                        childsItem = childs[j].children;
                        for (var k = 0; k < childsItem.length; k++) {
                            html += "<div class=\"sup-menu-box\">" +
                                "<p>" +
                                "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/icon-kuqu.png\"/></span>" +
                                "<a href=\"#\" onclick=\"clickDept('" + childsItem[k].code + "')\">" + childsItem[k].name + "</a>" +
                                "</p>" +
                                "</div>";
                        }
                    }
                    html += "</li>" +
                        "</ul>";
                }
            }
            html += "</div>" +
                "</div>";
        }
 
        $("#menuDiv").html(html);
    }
}
 
 
function renderNum() {
    $("#foodSum").html(gisData.deptNum);
 
    let deptNum = 0;
    var foodNumPerHtml = '';
    for (var i = 0; i < gisData.deptList.length; i++) {
        if ('0.0' != gisData.deptList[i].percent) {
            foodNumPerHtml += '<li><div class="con" style="background-color: rgba(' + foodNumPerColors[i] + ',.05);">';
            foodNumPerHtml += '<div class="dot" style="background-color: rgb(' + foodNumPerColors[i] + ');"></div>';
            foodNumPerHtml += '<div class="num" style="color: rgb(' + foodNumPerColors[i] + ');">' + gisData.deptList[i].percent + '%</div>';
            foodNumPerHtml += '<div class="type">' + gisData.deptList[i].name + '</div>';
            foodNumPerHtml += '</div></li>';
            deptNum += 1;
        }
 
    }
    $("#foodSum").html(deptNum);
    $("#foodNumPer").html(foodNumPerHtml);
    if (gisData.deptList.length > 0) {
        var varietyChart = breedChart;
        varietyChart.option.series[0].data = gisData.deptList;
        varietyChart.option.color = getHexColorsFromRGB(foodNumPerColors, gisData.deptList.length);
        varietyChart.chart.setOption(varietyChart.option, true);
        breedChart = varietyChart;
    }
    modelingBarChartLoad("ss");
}
 
 
/**
 * 将 RGB 格式颜色转换为十六进制格式
 * @param rgbColors RGB 颜色数组
 * @param count 需要的颜色数量
 * @returns {Array} 十六进制颜色数组
 */
function getHexColorsFromRGB(rgbColors, count) {
    var hexColors = [];
    for (var i = 0; i < count && i < rgbColors.length; i++) {
        var rgb = rgbColors[i].split(',');
        var r = parseInt(rgb[0]);
        var g = parseInt(rgb[1]);
        var b = parseInt(rgb[2]);
        var hex = '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
        hexColors.push(hex);
    }
    return hexColors;
}
 
 
 
 
/**
 * 格式化日期
 * @param fmt
 * @param date
 * @return {*}
 */
function formatDate(fmt, date) {
    var ret;
    const opt = {
        "Y+": date.getFullYear().toString(),        // 年
        "m+": (date.getMonth() + 1).toString(),     // 月
        "d+": date.getDate().toString(),            // 日
        "H+": date.getHours().toString(),           // 时
        "M+": date.getMinutes().toString(),         // 分
        "S+": date.getSeconds().toString()          // 秒
        // 有其他格式化字符需求可以继续添加,必须转化成字符串
    };
    for (var k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
        }
    }
    return fmt;
}
 
 
/**
 * 格式化日期
 * @param fmt
 * @param date
 * @return {*}
 */
function formatDate(fmt, date) {
    var ret;
    const opt = {
        "Y+": date.getFullYear().toString(), // 年
        "m+": (date.getMonth() + 1).toString(), // 月
        "d+": date.getDate().toString(), // 日
        "H+": date.getHours().toString(), // 时
        "M+": date.getMinutes().toString(), // 分
        "S+": date.getSeconds().toString() // 秒
        // 有其他格式化字符需求可以继续添加,必须转化成字符串
    };
    for (let k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
        }
    }
    return fmt;
}
 
/**
 *获取当前星期几
 */
function getWeekDate() {
    var now = new Date();
    var day = now.getDay();
    var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    var week = weeks[day];
    return week;
}
 
var navBarDateDom = document.getElementById('navBarDate');
var navBarTimeDom = document.getElementById('navBarTime');
var navBarWeekDom = document.getElementById('navBarWeek');
 
/*刷新时间*/
setInterval(function () {
    navBarDateDom.innerHTML = formatDate('mm月dd日', new Date());
    navBarTimeDom.innerHTML = formatDate('HH:MM:SS', new Date());
    navBarWeekDom.innerHTML = getWeekDate();
}, 1000)
 
$(function () {
    $('.m-nav .tit').click(function () {
        $(this).siblings('.sub').stop().slideToggle();
 
    });
    $('.c-left .close').on('click', function () {
        $('.c-left').addClass('hidden')
    });
    $('.c-left .o-btn').on('click', function () {
        $('.c-left').removeClass('hidden')
    });
    $('.c-right .close').on('click', function () {
        $('.c-right').addClass('hidden')
    });
    $('.c-right .o-btn').on('click', function () {
        $('.c-right').removeClass('hidden')
    });
 
});