|
|
|
@ -0,0 +1,36 @@
|
|
|
|
|
package com.shxy.xymanager_framework.mqtt;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalPositions;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
|
import com.shxy.xymanager_common.model.mqtt.CommonData;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalPositionsMapper;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalExtService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class GPSHandler {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
TerminalExtService terminalExtService;
|
|
|
|
|
@Resource
|
|
|
|
|
TerminalPositionsMapper terminalPositionsMapper;
|
|
|
|
|
|
|
|
|
|
public void handleUpload(CommonData data, String deviceId) throws Exception {
|
|
|
|
|
Terminals term = terminalExtService.getByCmdid(deviceId);
|
|
|
|
|
if (term == null) {
|
|
|
|
|
log.error("mqtt收到LongitudeAndLatitudeInfo,但是该装置" + deviceId + "不存在");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.info("mqtt消息LongitudeAndLatitudeInfo " + deviceId + " " + data.getGwLatitude() + "," + data.getGwLongitude());
|
|
|
|
|
TerminalPositions record = terminalPositionsMapper.selectByPrimaryKey(term.getId());
|
|
|
|
|
if (record != null) {
|
|
|
|
|
record.setLatitude(data.getGwLatitude());
|
|
|
|
|
record.setLongitude(data.getGwLongitude());
|
|
|
|
|
terminalPositionsMapper.updateByPrimaryKey(record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|