czt
2025-05-26 71df484843f8df041db16e263851775a7c8e00b6
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
//根据浏览器中的地址初始化WS的路径
function initWsUrl() {
    //http://ibms.fzzygf.com
    //http://127.0.0.1:8080/igds
    var href = window.location.href;
    var arrUrl = href.split("//");
    href = arrUrl[1];
    arrUrl = href.split("/");
    //如果没有配置contextPath
    if (arrUrl.length == 1) {
        return "ws://" + arrUrl[0] + "/websocket";
    }
    //如果contextPath = igds
    if ("igds" == arrUrl[1]) {
        return "ws://" + arrUrl[0] + "/" + arrUrl[1] + "/websocket";
    }
    //如果contextPath = zxlk
    if ("zxlk" == arrUrl[1]) {
        return "ws://" + arrUrl[0] + "/" + arrUrl[1] + "/websocket";
    }
    return "ws://" + arrUrl[0] + "/websocket";
};
 
/**
 *
 * @param deptId 分库编码
 * @param bizType 业务编号
 * @param bizTag 自定义业务标签 如果为null默认取common
 * @param userId 当前用户Id
 */
function initWS(deptId, bizType, bizTag, userId) {
    if (null == bizTag) bizTag = "common";
    var wsPath = initWsUrl() + "/" + deptId + "/" + bizType + "/" + bizTag + "/" + userId;
    if (typeof (WebSocket) == "undefined") {
        layer.msg("您的浏览器不支持WebSocket,请使用主流浏览器");
        return;
    }
    // 创建连接
    var socket = new WebSocket(wsPath);
    // 打开事件
    socket.onopen = function () {
        socket.send(bizType);
    };
    // 获得消息事件是后台穿件的WebPocket对象信息
    socket.onmessage = function (result) {
        var pocket = JSON.parse(result.data);
        socketOnMessage(pocket);
    };
    // 关闭事件
    socket.onclose = function () {
        console.log("Socket closed……");
    };
 
    // 关闭WebSocket连接
    function closeWebSocket() {
        socket.close();
    }
 
    // 发生了错误事件
    socket.onerror = function () {
        alert("Socket error……");
    };
 
    $(window).unload(function () {
        closeWebSocket();
    });
}
 
// 出入库专用连接,添加流程节点参数
function initInoutWS(companyId, bizType, progress, userId) {
    var wsPath = initWsUrl() + "/" + companyId + "/" + bizType + "/" + progress
        + "/" + userId;
    if (typeof (WebSocket) == "undefined") {
        layer.msg("您的浏览器不支持WebSocket,请使用主流浏览器");
        return;
    }
    // 实现化WebSocket对象,指定要连接的服务器地址与端口  建立连接
    var socket = new WebSocket(wsPath);
    // 打开事件
    socket.onopen = function () {
        socket.send(bizType);
    };
    // 获得消息事件是后台穿件的WebPocket对象信息
    socket.onmessage = function (result) {
        var pocket = JSON.parse(result.data);
        socketOnMessage(pocket);
    };
    // 关闭事件
    socket.onclose = function () {
        console.log("Socket closed……");
    };
 
    // 关闭WebSocket连接
    function closeWebSocket() {
        socket.close();
    }
    // 发生了错误事件
    socket.onerror = function () {
        alert("Socket error……");
    }
    $(window).unload(function () {
        socket.close();
    });
};
 
function INOUT_PROGRESS_MSG(code) {
    if (InoutProgress.REGISTER == code) return "登记";
    if (InoutProgress.CHECK == code) return "化验";
    if (InoutProgress.HANDLE == code) return "值仓";
    if (InoutProgress.WEIGHT_TAG == code) return "称重";
    if (InoutProgress.WEIGHT_FULL == code) return "满车称重";
    if (InoutProgress.WEIGHT_EMPTY == code) return "空车称重";
    if (InoutProgress.PAY == code) return "支付";
    if (InoutProgress.CARD_BACK == code) return "卡回收";
    if (InoutProgress.RECORD == code) return "流程完成";
    return "未知";
};
 
/**
 * 根据状态编码返回中文
 * @param code
 */
function DEPOT_STATUS_MSG(code) {
    if (code == DepotStatus.S_01) return "空仓";
    if (code == DepotStatus.S_02) return "入库中";
    if (code == DepotStatus.S_03) return "封仓";
    if (code == DepotStatus.S_04) return "出库中";
    if (code == DepotStatus.S_05) return "封仓-气调中";
    if (code == DepotStatus.S_06) return "封仓-熏蒸中";
    if (code == DepotStatus.S_07) return "封仓-通风中";
    if (code == DepotStatus.S_08) return "封仓-温控中";
    if (code == DepotStatus.S_09) return "其他";
    return code;
}
 
/**
 * fmt 时间格式化例如:yyyy-MM-dd hh:mm:ss date 时间 return 字符串
 */
function dateFtt(fmt, date) {
    if (!date) return "";
    var o = {
        "M+": date.getMonth() + 1, // 月份
        "d+": date.getDate(), // 日
        "h+": date.getHours(), // 小时
        "m+": date.getMinutes(), // 分
        "s+": date.getSeconds(), // 秒
        "q+": Math.floor((date.getMonth() + 3) / 3), // 季度
        "S": date.getMilliseconds()
        // 毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "")
            .substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
                : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
 
function dateFtt2(fmt, date) {
    if (!date) return "";
    var date2 = new Date(date);
    return dateFtt(fmt, date2);
}
 
// 刷新时间
function initTime() {
    setInterval(function () {
        $("#navBarDate").html(formatDate('mm月dd日', new Date()));
        $("#navBarTime").html(formatDate('HH:MM:SS', new Date()));
        $("#navBarWeek").html(getWeekDate());
    }, 1000);
}
 
/**
 * 格式化日期
 *
 * @param fmt
 * @param date
 * @return {*}
 */
function formatDate(fmt, date) {
    var ret;
    var 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;
}
 
/**
 * 获取当前星期几
 */
function getWeekDate() {
    var now = new Date();
    var day = now.getDay();
    var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    var week = weeks[day];
    return week;
}
 
/**
 * 切换页面
 * @param pageTag
 */
function changePage(pageTag) {
    var url = "../dept-board/index";
 
    if ("inout" == pageTag) {
        url = "../dept-board/inout";
    }
    if ("ai" == pageTag) {
        url = "../dept-board/ai";
    }
    if ("video" == pageTag) {
        url = "../dept-board/video";
    }
    //后台管理首页
    if ("backstage" == pageTag) {
        url = "../index";
        window.parent.open(url, "_self");
        return;
    }
 
    window.location.href = url;
}