CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
//根据浏览器中的地址初始化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 "维修中";
    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);
}