|
@@ -7,6 +7,8 @@ import com.usky.iot.domain.BaseAppInfo;
|
|
|
import com.usky.iot.mapper.BaseAppInfoMapper;
|
|
|
import com.usky.iot.service.BaseAppInfoService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.iot.service.config.rabbitmq.RabbitMQConfig;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -14,8 +16,11 @@ import org.springframework.web.context.request.RequestAttributes;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -34,6 +39,12 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
|
|
|
@Value("${agBox.push}")
|
|
|
private Integer pushFlag;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RabbitMQConfig rabbitMQConfig;
|
|
|
+
|
|
|
public String getIpAddress(HttpServletRequest request) {
|
|
|
String ip = request.getHeader("X-Forwarded-For");
|
|
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
|
@@ -68,6 +79,13 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
|
|
|
baseAppInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
baseAppInfo.setCreateTime(LocalDateTime.now());
|
|
|
baseAppInfo.setTenantId(SecurityUtils.getTenantId());
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("deviceId",baseAppInfo.getDeviceId());
|
|
|
+ map.put("userName",baseAppInfo.getUserName());
|
|
|
+ map.put("createTime",baseAppInfo.getCreateTime());
|
|
|
+ rabbitTemplate.convertAndSend(rabbitMQConfig.infoFEventExchange,"",JSONObject.toJSONString(map));
|
|
|
+
|
|
|
this.save(baseAppInfo);
|
|
|
if (pushFlag.equals(1)){
|
|
|
JSONObject a = remotePatrolAgboxService.updateHeart(jsonObj.toJSONString());
|