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
package com.ld.igds.oa.view;
 
import com.ld.igds.io.MRemoteManager;
import com.ld.igds.io.RemoteGpsMacService;
import com.ld.igds.io.constant.OrderRespEnum;
import com.ld.igds.io.request.GpsMacRequest;
import com.ld.igds.io.response.ProtocolResponse;
import com.ld.igds.models.OAAsset;
import com.ld.igds.oa.dto.GpsData;
import com.ld.igds.oa.service.CoreGpsService;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
/**
 *查询资产设备位置
 * 
 * @author:
 * @description:
 * @version:
 * @data:
 *
 */
@Component
public class GpsConfManager {
 
    @Autowired
    private MRemoteManager remoteManager;
 
    @Autowired
    private CoreGpsService coreGpsService;
 
 
    public String queryLocation(OAAsset data) {
        if (StringUtils.isEmpty(data.getGpsPhone())) {
            return "执行失败:该设备尚未绑定GPS定位设备,无法查询位置信息";
        }
 
        GpsData gps = coreGpsService.getGpsByPhone(data.getGpsPhone());
 
        //根据绑定的GPS设备查询协议
        RemoteGpsMacService remoteGpsService = remoteManager.getRemoteGpsMacService(gps.getProtocol());
        if (null == remoteGpsService) {
            return "执行失败:系统没有检测到当前定位设备的协议实现!";
        }
 
        GpsMacRequest param = new GpsMacRequest();
        param.setCompanyId(data.getCompanyId());
        param.setIp(gps.getIp());
        param.setPort(gps.getPort());
        param.setPhone(gps.getPhone());
 
        ProtocolResponse<GpsData> result = remoteGpsService.queryLocation(param);
 
        if (!OrderRespEnum.ORDER_SUCCESS.getCode().equals(result.getCode())) {
            return "执行失败:" + result.getMsg();
        }
        return "命令执行成功,请到资产定位中查看设备位置!";
    }
}