jiazx0107@163.com
2023-11-18 8a7b05e0683ff738233d39295e4ad169b72efc95
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
package com.fzzy.protocol.sdkhk;
 
import com.fzzy.api.data.GatewayDeviceProtocol;
import com.fzzy.gateway.api.GatewaySyncLprService;
import com.fzzy.gateway.data.BaseReqData;
import com.fzzy.gateway.data.BaseResp;
import com.fzzy.gateway.entity.GatewayDevice;
import com.fzzy.protocol.sdkhk.lpr.AlarmLpr;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 网关与设备之间的通讯-海康SDK
 */
@Slf4j
@Component
public class HkGatewaySyncLprImpl implements GatewaySyncLprService {
 
 
    private AlarmLpr alarmLpr = new AlarmLpr();
 
    @Override
    public String getLprProtocol() {
        return GatewayDeviceProtocol.DEVICE_LPR_SDK_HK.getCode();
    }
 
    @Override
    public BaseResp syncLpr(BaseReqData reqData) {
        return new BaseResp(500, "系统不支持手动触发获取");
    }
 
    @Override
    public BaseResp initLpr(BaseReqData reqData) {
        try {
            String msg = alarmLpr.initSdk();
 
            log.info("--------初始化HK-SDK-------{}", msg);
 
            Thread.sleep(500);
 
            GatewayDevice device = reqData.getDevice();
            //如果已经上线先离线
            String status = HKUtils.getStatus(reqData.getDeviceId());
            if ("Y".equals(status)) {
                alarmLpr.logout(reqData.getIndex(), device.getIp(), device.getPort());
                Thread.sleep(500);
            }
 
            //重新登陆
            msg = alarmLpr.login(reqData.getIndex(), device.getIp(), device.getPort(), device.getUserName(), device.getPassword());
 
            if (HKUtils.RESULT_SUCCESS.equals(msg)) {
                HKUtils.updateStatus(device.getDeviceId(), "Y");
            }
 
        } catch (Exception e) {
            log.error("----------------初始化车牌识别执行识别失败----------------------{}", e);
 
            return new BaseResp(500,"执行失败:"+e.getMessage());
        }
 
        return new BaseResp();
    }
}