feat():实时数据通过远程调用展示
parent
7379139e25
commit
42ede316cb
|
@ -34,6 +34,9 @@
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车联网客户业务系统启动类 MuYuCustomerBusinessApplication
|
* 车联网客户业务系统启动类 MuYuCustomerBusinessApplication
|
||||||
|
@ -18,6 +19,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
//@EnableScheduling
|
||||||
public class MuYuCustomerBusinessApplication {
|
public class MuYuCustomerBusinessApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(MuYuCustomerBusinessApplication.class, args);
|
SpringApplication.run(MuYuCustomerBusinessApplication.class, args);
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.customer.business.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
/**
|
||||||
|
* 没有实例化RestTemplate时,初始化RestTemplate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ConditionalOnMissingBean(RestTemplate.class)
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate(){
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
return restTemplate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,16 +3,11 @@ package com.muyu.customer.business.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
@ -108,4 +103,10 @@ public class FenceController extends BaseController {
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
return toAjax(fenceService.removeBatchByIds(ids));
|
return toAjax(fenceService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Scheduled(cron = "*/1 * * * * ?")
|
||||||
|
@PostMapping("/getConn")
|
||||||
|
public Result getConn(@RequestBody Vehicle vehicle) {
|
||||||
|
return fenceService.getConn(vehicle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,11 +110,13 @@ public class VehicleController extends BaseController {
|
||||||
return toAjax(vehicleService.removeBatchByIds(ids));
|
return toAjax(vehicleService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private VehicleMapper vehicleMapper;
|
// private VehicleMapper vehicleMapper;
|
||||||
|
//
|
||||||
|
// @GetMapping("/list/all")
|
||||||
|
// public Result<List<Vehicle>> findAll () {
|
||||||
|
// return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/list/all")
|
|
||||||
public Result<List<Vehicle>> findAll () {
|
|
||||||
return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.muyu.customer.business.service;
|
package com.muyu.customer.business.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.customer.business.domain.Fence;
|
import com.muyu.customer.business.domain.Fence;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电子围栏Service接口
|
* 电子围栏Service接口
|
||||||
|
@ -19,4 +22,5 @@ public interface FenceService extends IService<Fence> {
|
||||||
*/
|
*/
|
||||||
List<Fence> list(Fence fence);
|
List<Fence> list(Fence fence);
|
||||||
|
|
||||||
|
Result getConn(Vehicle vehicle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,19 @@ package com.muyu.customer.business.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.customer.business.mapper.FenceMapper;
|
import com.muyu.customer.business.mapper.FenceMapper;
|
||||||
import com.muyu.customer.business.domain.Fence;
|
import com.muyu.customer.business.domain.Fence;
|
||||||
import com.muyu.customer.business.service.FenceService;
|
import com.muyu.customer.business.service.FenceService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电子围栏Service业务层处理
|
* 电子围栏Service业务层处理
|
||||||
|
@ -20,6 +25,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements FenceService {
|
public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements FenceService {
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电子围栏列表
|
* 查询电子围栏列表
|
||||||
|
@ -50,4 +57,11 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implement
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result getConn(Vehicle vehicle) {
|
||||||
|
Object forObject = restTemplate.getForObject("http://192.168.43.154:88/test/getList?vin="+vehicle.getVin(), Object.class);
|
||||||
|
|
||||||
|
return Result.success(forObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue