feat():实时数据通过远程调用展示

baize
baize 2024-06-18 18:57:20 +08:00
parent 7379139e25
commit 42ede316cb
7 changed files with 61 additions and 15 deletions

View File

@ -34,6 +34,9 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -7,6 +7,7 @@ import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* MuYuCustomerBusinessApplication
@ -18,6 +19,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
//@EnableScheduling
public class MuYuCustomerBusinessApplication {
public static void main (String[] args) {
SpringApplication.run(MuYuCustomerBusinessApplication.class, args);

View File

@ -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 {
/**
* RestTemplateRestTemplate
* @return
*/
@ConditionalOnMissingBean(RestTemplate.class)
@Bean
public RestTemplate restTemplate(){
RestTemplate restTemplate = new RestTemplate();
return restTemplate;
}
}

View File

@ -3,16 +3,11 @@ package com.muyu.customer.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.customer.business.domain.Vehicle;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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 org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
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) {
return toAjax(fenceService.removeBatchByIds(ids));
}
// @Scheduled(cron = "*/1 * * * * ?")
@PostMapping("/getConn")
public Result getConn(@RequestBody Vehicle vehicle) {
return fenceService.getConn(vehicle);
}
}

View File

@ -110,11 +110,13 @@ public class VehicleController extends BaseController {
return toAjax(vehicleService.removeBatchByIds(ids));
}
@Autowired
private VehicleMapper vehicleMapper;
// @Autowired
// 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<>()));
}
}

View File

@ -1,8 +1,11 @@
package com.muyu.customer.business.service;
import java.util.List;
import com.muyu.common.core.domain.Result;
import com.muyu.customer.business.domain.Fence;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.customer.business.domain.Vehicle;
/**
* Service
@ -19,4 +22,5 @@ public interface FenceService extends IService<Fence> {
*/
List<Fence> list(Fence fence);
Result getConn(Vehicle vehicle);
}

View File

@ -2,14 +2,19 @@ package com.muyu.customer.business.service.impl;
import java.util.List;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.customer.business.domain.Vehicle;
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 com.muyu.customer.business.mapper.FenceMapper;
import com.muyu.customer.business.domain.Fence;
import com.muyu.customer.business.service.FenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.web.client.RestTemplate;
/**
* Service
@ -20,6 +25,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@Slf4j
@Service
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);
}
@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);
}
}