diff --git a/muyu-common/muyu-common-saas/pom.xml b/muyu-common/muyu-common-saas/pom.xml index b261b51..503f4eb 100644 --- a/muyu-common/muyu-common-saas/pom.xml +++ b/muyu-common/muyu-common-saas/pom.xml @@ -34,6 +34,9 @@ org.springframework spring-webmvc - + + com.muyu + muyu-common-security + diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/MuYuCustomerBusinessApplication.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/MuYuCustomerBusinessApplication.java index de544fc..a5d0d96 100644 --- a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/MuYuCustomerBusinessApplication.java +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/MuYuCustomerBusinessApplication.java @@ -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); diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/config/RestTemplateConfig.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/config/RestTemplateConfig.java new file mode 100644 index 0000000..5b0d9ff --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/config/RestTemplateConfig.java @@ -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; + } +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/FenceController.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/FenceController.java index 61fd27c..acf9ebd 100644 --- a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/FenceController.java +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/FenceController.java @@ -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 remove(@PathVariable List ids) { return toAjax(fenceService.removeBatchByIds(ids)); } + +// @Scheduled(cron = "*/1 * * * * ?") + @PostMapping("/getConn") + public Result getConn(@RequestBody Vehicle vehicle) { + return fenceService.getConn(vehicle); + } } diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/VehicleController.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/VehicleController.java index f416751..e33d9a2 100644 --- a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/VehicleController.java +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/VehicleController.java @@ -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> findAll () { +// return Result.success(vehicleMapper.selectList(new QueryWrapper<>())); +// } + - @GetMapping("/list/all") - public Result> findAll () { - return Result.success(vehicleMapper.selectList(new QueryWrapper<>())); - } } diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/FenceService.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/FenceService.java index b9879c9..d2ba85e 100644 --- a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/FenceService.java +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/FenceService.java @@ -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 { */ List list(Fence fence); + Result getConn(Vehicle vehicle); } diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/FenceServiceImpl.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/FenceServiceImpl.java index bd60d0c..7cb72dd 100644 --- a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/FenceServiceImpl.java +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/FenceServiceImpl.java @@ -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 implements FenceService { + @Autowired + private RestTemplate restTemplate; /** * 查询电子围栏列表 @@ -50,4 +57,11 @@ public class FenceServiceImpl extends ServiceImpl 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); + } }