Compare commits
12 Commits
master
...
dev.repair
Author | SHA1 | Date |
---|---|---|
|
3b35565404 | |
|
846a03f75c | |
|
542a656dc6 | |
|
a834f9d1bd | |
|
960d68f72e | |
|
2c5387f048 | |
|
f57deada17 | |
|
ef0311d362 | |
|
5bb0737c82 | |
|
d1440fb706 | |
|
3ed255fe1e | |
|
1d91e51199 |
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有故障缓存服务
|
||||||
|
*/
|
||||||
|
public class AllFaultCacheService extends CacheAbsBacis {
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "Allfault:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("Allfault:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.Fence;
|
||||||
|
import com.muyu.domain.req.FenceReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有电子围栏缓存
|
||||||
|
*/
|
||||||
|
public class AllFenceCahceService extends CacheAbsBacis<String, FenceReq> {
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "Allfence:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("Allfence:info:", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.resp.MessageValueListResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文模版缓存
|
||||||
|
*/
|
||||||
|
public class AllMessageValueCacheService extends CacheAbsBacis<String, List<MessageValueListResp>> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "allmessagevalue:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("allmessagevalue:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.Vehicle;
|
||||||
|
import com.muyu.domain.req.VehicleAddReq;
|
||||||
|
import com.muyu.domain.req.VehicleManageReq;
|
||||||
|
import com.muyu.domain.resp.VehicleManageResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有车辆缓存
|
||||||
|
*/
|
||||||
|
public class AllVehicleCacheService extends CacheAbsBacis<String, VehicleManageResp> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存key前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "allvehicle:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("allvehicle:info:", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.VehicleType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有车辆类型缓存
|
||||||
|
*/
|
||||||
|
public class AllVehicleTypeCacheService extends CacheAbsBacis<String, VehicleType> {
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "vehicleType:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("vehicleType:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,9 @@ package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
import com.muyu.common.cache.CacheAbsBacis;
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
import com.muyu.domain.Fence;
|
import com.muyu.domain.Fence;
|
||||||
|
import com.muyu.domain.resp.FenceResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电子围栏缓存
|
* 电子围栏缓存
|
||||||
|
@ -21,4 +24,5 @@ public class FenceCahceService extends CacheAbsBacis<String, Fence> {
|
||||||
public String decode(String key) {
|
public String decode(String key) {
|
||||||
return key.replace("fence:info:", "");
|
return key.replace("fence:info:", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.MessageTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文模版缓存
|
||||||
|
*/
|
||||||
|
public class MessageTemplateCacheService extends CacheAbsBacis<String, MessageTemplate> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "messageTemplate:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("messageTemplate:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.MessageValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文模版缓存
|
||||||
|
*/
|
||||||
|
public class MessageValueCacheService extends CacheAbsBacis<String, MessageValue> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "messagevalue:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("messagevalue:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import com.muyu.common.cache.CacheAbsBacis;
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆缓存
|
* 添加车辆缓存
|
||||||
*/
|
*/
|
||||||
public class VehicleCacheService extends CacheAbsBacis<String, Vehicle> {
|
public class VehicleCacheService extends CacheAbsBacis<String, Vehicle> {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
|
import com.muyu.common.cache.CacheAbsBacis;
|
||||||
|
import com.muyu.domain.VehicleType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆类型
|
||||||
|
*/
|
||||||
|
public class VehicleTypeCacheService extends CacheAbsBacis<String, VehicleType> {
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String keyPre() {
|
||||||
|
return "vehicleType:info:";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String decode(String key) {
|
||||||
|
return key.replace("vehicleType:info:", "");
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,11 +14,11 @@ public class WarnRuleCacheService extends CacheAbsBacis<String, WarnRule> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String keyPre() {
|
public String keyPre() {
|
||||||
return "warn:info:";
|
return "warnRule:info:";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decode(String key) {
|
public String decode(String key) {
|
||||||
return key.replace("warn:info:", "");
|
return key.replace("warnRule:info:", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.muyu.domain.WarnRule;
|
||||||
import com.muyu.domain.WarnStrategy;
|
import com.muyu.domain.WarnStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预警规则缓存服务
|
* 预警策略缓存服务
|
||||||
*/
|
*/
|
||||||
public class WarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy> {
|
public class WarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy> {
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,11 +15,11 @@ public class WarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String keyPre() {
|
public String keyPre() {
|
||||||
return "warn:info:";
|
return "warnStrategy:info:";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decode(String key) {
|
public String decode(String key) {
|
||||||
return key.replace("warn:info:", "");
|
return key.replace("warnStrategy:info:", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
com.muyu.enterprise.cache.VehicleCacheService
|
com.muyu.enterprise.cache.AllFaultCacheService
|
||||||
|
com.muyu.enterprise.cache.AllFenceCahceService
|
||||||
|
com.muyu.enterprise.cache.AllMessageValueCacheService
|
||||||
|
com.muyu.enterprise.cache.AllVehicleCacheService
|
||||||
|
com.muyu.enterprise.cache.AllVehicleTypeCacheService
|
||||||
com.muyu.enterprise.cache.FaultCacheService
|
com.muyu.enterprise.cache.FaultCacheService
|
||||||
com.muyu.enterprise.cache.FenceCahceService
|
com.muyu.enterprise.cache.FenceCahceService
|
||||||
|
com.muyu.enterprise.cache.MessageTemplateCacheService
|
||||||
|
com.muyu.enterprise.cache.MessageValueCacheService
|
||||||
|
com.muyu.enterprise.cache.VehicleCacheService
|
||||||
|
com.muyu.enterprise.cache.VehicleTypeCacheService
|
||||||
com.muyu.enterprise.cache.WarnRuleCacheService
|
com.muyu.enterprise.cache.WarnRuleCacheService
|
||||||
com.muyu.enterprise.cache.WarnStrategyCacheService
|
com.muyu.enterprise.cache.WarnStrategyCacheService
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,6 @@ package com.muyu.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
@ -44,7 +41,16 @@ public class VehicleType extends BaseEntity {
|
||||||
* 报文模版外键
|
* 报文模版外键
|
||||||
*/
|
*/
|
||||||
@Schema(type = "Integer",description = "报文模版外键")
|
@Schema(type = "Integer",description = "报文模版外键")
|
||||||
private Integer messageTemplateId;
|
private Long messageTemplateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加车辆类型
|
||||||
|
*/
|
||||||
|
public static VehicleType addBuilder(VehicleType vehicleType) {
|
||||||
|
return VehicleType.builder().
|
||||||
|
vehicleTypeId(vehicleType.getVehicleTypeId()).
|
||||||
|
vehicleTypeName(vehicleType.getVehicleTypeName()).
|
||||||
|
build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.domain.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定围栏组请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Tag(name = "绑定围栏组参数")
|
||||||
|
public class BoundFenceGroupReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆Id
|
||||||
|
*/
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 围栏组Ids
|
||||||
|
*/
|
||||||
|
private List<Long> fenceGroupIds;
|
||||||
|
}
|
|
@ -28,7 +28,9 @@ import java.security.Security;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏信息
|
||||||
|
*/
|
||||||
@RequestMapping("/elect")
|
@RequestMapping("/elect")
|
||||||
@RestController
|
@RestController
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@ -54,7 +56,7 @@ public class ElectController extends BaseController {
|
||||||
public Result<TableDataInfo<FenceResp>> showList(@RequestBody @Validated FenceReq req) {
|
public Result<TableDataInfo<FenceResp>> showList(@RequestBody @Validated FenceReq req) {
|
||||||
startPage();
|
startPage();
|
||||||
List<FenceResp> list = electService.selectFenceList(req);
|
List<FenceResp> list = electService.selectFenceList(req);
|
||||||
fenceCahceService.get(String.valueOf(req));
|
//将列表存到Redis
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,5 +157,4 @@ public class ElectController extends BaseController {
|
||||||
return Result.success(fences);
|
return Result.success(fences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.muyu.enterprise.controller;
|
package com.muyu.enterprise.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import com.muyu.domain.MessageTemplate;
|
import com.muyu.domain.MessageTemplate;
|
||||||
import com.muyu.domain.req.MessageTemplateAddReq;
|
import com.muyu.domain.req.MessageTemplateAddReq;
|
||||||
import com.muyu.domain.resp.MessageTemplateListResp;
|
import com.muyu.domain.resp.MessageTemplateListResp;
|
||||||
|
import com.muyu.enterprise.cache.MessageTemplateCacheService;
|
||||||
import com.muyu.enterprise.service.MessageTemplateService;
|
import com.muyu.enterprise.service.MessageTemplateService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -30,6 +33,10 @@ public class MessageTemplateController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageTemplateService messageTemplateService;
|
private MessageTemplateService messageTemplateService;
|
||||||
|
|
||||||
|
//缓存
|
||||||
|
@Autowired
|
||||||
|
private MessageTemplateCacheService templateCacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模版列表查询
|
* 报文模版列表查询
|
||||||
*1
|
*1
|
||||||
|
@ -55,8 +62,14 @@ public class MessageTemplateController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/")
|
@PostMapping("/")
|
||||||
public Result<String> save(@RequestBody MessageTemplateAddReq messageTemplateAddReq) {
|
public Result<String> save(@RequestBody MessageTemplateAddReq messageTemplateAddReq) {
|
||||||
messageTemplateService.save(MessageTemplate.addBuild(messageTemplateAddReq));
|
boolean save = messageTemplateService.save(MessageTemplate.addBuild(messageTemplateAddReq));
|
||||||
return Result.success("添加成功");
|
//获取用户信息
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
//获取租户唯一标识
|
||||||
|
String databaseName = loginUser.getSysUser().getDatabaseName();
|
||||||
|
//添加到缓存
|
||||||
|
templateCacheService.put(databaseName+messageTemplateAddReq.getMessageTemplateName(), MessageTemplate.addBuild(messageTemplateAddReq));
|
||||||
|
return Result.success(save? "新增成功" : "新增失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.muyu.enterprise.controller;
|
||||||
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||||
|
import com.muyu.enterprise.cache.AllVehicleCacheService;
|
||||||
import com.muyu.enterprise.cache.VehicleCacheService;
|
import com.muyu.enterprise.cache.VehicleCacheService;
|
||||||
import com.muyu.enterprise.service.VehicleService;
|
import com.muyu.enterprise.service.VehicleService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
@ -19,9 +21,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,11 +45,10 @@ public class VehicleController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleService vehicleService;
|
private VehicleService vehicleService;
|
||||||
|
|
||||||
//车辆缓存
|
//添加车辆缓存
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleCacheService vehicleCacheService;
|
private VehicleCacheService vehicleCacheService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆管理列表
|
* 查询车辆管理列表
|
||||||
*
|
*
|
||||||
|
@ -56,6 +59,11 @@ public class VehicleController extends BaseController {
|
||||||
public Result<TableDataInfo<VehicleManageResp>> getVehicleList(@RequestBody VehicleManageReq vehicleManageReq) {
|
public Result<TableDataInfo<VehicleManageResp>> getVehicleList(@RequestBody VehicleManageReq vehicleManageReq) {
|
||||||
startPage();
|
startPage();
|
||||||
List<VehicleManageResp> list = vehicleService.getVehicleList(vehicleManageReq);
|
List<VehicleManageResp> list = vehicleService.getVehicleList(vehicleManageReq);
|
||||||
|
//将车辆信息存到Redis
|
||||||
|
List<Vehicle> vehicleList = vehicleService.list();
|
||||||
|
vehicleList.forEach(vehicle -> {
|
||||||
|
vehicleCacheService.put(vehicle.getVehicleVin(), vehicle);
|
||||||
|
});
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +152,10 @@ public class VehicleController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/addBoundFenceGroup")
|
@GetMapping("/addBoundFenceGroup")
|
||||||
@Operation(description = "车辆绑定围栏组")
|
@Operation(description = "车辆绑定围栏组")
|
||||||
public Result<String> boundFenceGroup(
|
public Result boundFenceGroup(
|
||||||
@Validated @RequestBody BoundMiddle boundMiddle){
|
@Validated @RequestBody BoundFenceGroupReq boundFenceGroupReq){
|
||||||
return null;
|
vehicleService.boundFenceGroup(boundFenceGroupReq);
|
||||||
|
return Result.success("绑定成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
package com.muyu.enterprise.controller;
|
package com.muyu.enterprise.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.domain.MessageValue;
|
||||||
import com.muyu.domain.VehicleType;
|
import com.muyu.domain.VehicleType;
|
||||||
|
import com.muyu.domain.req.MessageValueAddReq;
|
||||||
|
import com.muyu.domain.req.VehicleAddReq;
|
||||||
|
import com.muyu.enterprise.cache.VehicleCacheService;
|
||||||
|
import com.muyu.enterprise.cache.VehicleTypeCacheService;
|
||||||
import com.muyu.enterprise.service.VehicleTypeService;
|
import com.muyu.enterprise.service.VehicleTypeService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -30,6 +35,9 @@ public class VehicleTypeController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleTypeService vehicleTypeService;
|
private VehicleTypeService vehicleTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleTypeCacheService vehicleTypeCacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有车辆类型
|
* 查询所有车辆类型
|
||||||
* @return
|
* @return
|
||||||
|
@ -37,6 +45,29 @@ public class VehicleTypeController {
|
||||||
@RequestMapping(path = "/", method = RequestMethod.POST)
|
@RequestMapping(path = "/", method = RequestMethod.POST)
|
||||||
@Operation(summary = "车辆类型列表",description = "车辆类型列表")
|
@Operation(summary = "车辆类型列表",description = "车辆类型列表")
|
||||||
public Result<List<VehicleType>> findAll(){
|
public Result<List<VehicleType>> findAll(){
|
||||||
return Result.success(vehicleTypeService.list());
|
List<VehicleType> list = vehicleTypeService.list();
|
||||||
|
list.forEach(vehicleType -> {
|
||||||
|
vehicleTypeCacheService.put(String.valueOf(vehicleType.getVehicleTypeId()), vehicleType);
|
||||||
|
});
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加车辆类型
|
||||||
|
* @param vehicleType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/add")
|
||||||
|
@Operation(summary = "添加报文数据", description = "新增报文数据")
|
||||||
|
public Result<String> save(@RequestBody VehicleType vehicleType) {
|
||||||
|
boolean save = vehicleTypeService.save(vehicleType);
|
||||||
|
// //获取用户信息
|
||||||
|
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
// //获取租户唯一标识
|
||||||
|
// String databaseName = loginUser.getSysUser().getDatabaseName();
|
||||||
|
//存到redis
|
||||||
|
// vehicleTypeCacheService.put(databaseName+vehicleType.getVehicleTypeId(),vehicleType);
|
||||||
|
vehicleTypeCacheService.put(String.valueOf(vehicleType.getVehicleTypeId()),vehicleType);
|
||||||
|
return Result.success(save? "添加成功" : "添加失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,6 @@ public interface ElectMapper extends MPJBaseMapper<Fence> {
|
||||||
@Select("select * from fence where fence_id=#{fenceId}")
|
@Select("select * from fence where fence_id=#{fenceId}")
|
||||||
List<Fence> mapShow(@Param("fenceId") Long fenceId);
|
List<Fence> mapShow(@Param("fenceId") Long fenceId);
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 根据id查询车辆
|
|
||||||
// */
|
|
||||||
// Fence boundFence(@Param("fenceId") Long fenceId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电子围栏(终版)
|
* 查询电子围栏(终版)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,7 +28,16 @@ public interface FencegroupMapper extends MPJBaseMapper<FenceGroup> {
|
||||||
@Select("SELECT g.fence_group_id,g.group_type,g.priority,g.`status`,f.fence_id, group_CONCAT( f.fence_name ) AS fence_name FROM fence_group g LEFT JOIN middle m ON m.fence_group_id = g.fence_group_id LEFT JOIN fence f ON m.fence_id = f.fence_id GROUP BY g.fence_group_id")
|
@Select("SELECT g.fence_group_id,g.group_type,g.priority,g.`status`,f.fence_id, group_CONCAT( f.fence_name ) AS fence_name FROM fence_group g LEFT JOIN middle m ON m.fence_group_id = g.fence_group_id LEFT JOIN fence f ON m.fence_id = f.fence_id GROUP BY g.fence_group_id")
|
||||||
List<FenceGroup> showGroupList(FenceGroupReq req);
|
List<FenceGroup> showGroupList(FenceGroupReq req);
|
||||||
|
|
||||||
@Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection=\"fenceIds\" item=\"id\" separator=\",\"> (#{id},#{fenceGroupId}) </foreach>")
|
// @Insert("INSERT INTO `vehicle-basic`.`middle` (`fence_id`, `fence_group_id`) VALUES <foreach collection='fenceIds' item='id' separator=','> (#{id},#{fenceGroupId}) </foreach>")
|
||||||
|
// @Insert({ "<script>", "INSERT INTO user_role (user_id, role_id) VALUES ", "<foreach collection='roleIds' item='roleId' separator=','>", "(#{userId}, #{roleId})", "</foreach>", "</script>" })
|
||||||
|
@Insert({
|
||||||
|
"<script>",
|
||||||
|
"INSERT INTO `vehicle-basic`.`middle` (fence_id, fence_group_id) VALUES ",
|
||||||
|
"<foreach collection='fenceIds' item='id' separator=','>",
|
||||||
|
"(#{id}, #{fenceGroupId})",
|
||||||
|
"</foreach>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
void addMiddle(@Param("fenceIds") Integer[] fenceIds,@Param("fenceGroupId") Long fenceGroupId);
|
void addMiddle(@Param("fenceIds") Integer[] fenceIds,@Param("fenceGroupId") Long fenceGroupId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.muyu.enterprise.mapper;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
|
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||||
import com.muyu.domain.req.VehicleManageReq;
|
import com.muyu.domain.req.VehicleManageReq;
|
||||||
import com.muyu.domain.resp.VehicleManageResp;
|
import com.muyu.domain.resp.VehicleManageResp;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
@ -28,11 +30,6 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
|
||||||
*/
|
*/
|
||||||
List<VehicleManageResp> findAll(VehicleManageReq vehicleManageReq);
|
List<VehicleManageResp> findAll(VehicleManageReq vehicleManageReq);
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆绑定围栏组
|
|
||||||
*/
|
|
||||||
void bindFenceGroup(@Param("fenceGroupIds") Integer[] fenceGroupIds, @Param("vehicleId") Long vehicleId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据车辆vin查询模版id
|
* 根据车辆vin查询模版id
|
||||||
* @param vehicleVin
|
* @param vehicleVin
|
||||||
|
@ -40,4 +37,20 @@ public interface VehicleMapper extends MPJBaseMapper<Vehicle> {
|
||||||
*/
|
*/
|
||||||
@Select("SELECT t.message_template_id FROM vehicle v LEFT JOIN vehicle_type t ON v.vehicle_type_id = t.vehicle_type_id WHERE v.vehicle_vin = #{vehicleVin}")
|
@Select("SELECT t.message_template_id FROM vehicle v LEFT JOIN vehicle_type t ON v.vehicle_type_id = t.vehicle_type_id WHERE v.vehicle_vin = #{vehicleVin}")
|
||||||
Long findByVehicleVin(String vehicleVin);
|
Long findByVehicleVin(String vehicleVin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆绑定围栏组
|
||||||
|
* @param boundFenceGroupReq
|
||||||
|
*/
|
||||||
|
// @Insert("INSERT INTO `vehicle-basic`.`bound_middle` (`fence_group_id`,`vehicle_id`) VALUES <foreach collection=\"fenceGroupIds\" item=\"id\" separator=\",\"> (#{id},#{vehicleId}) </foreach>")
|
||||||
|
@Insert({
|
||||||
|
"<script>",
|
||||||
|
"INSERT INTO `vehicle-basic`.`bound_middle` (fence_group_id,vehicle_id) VALUES ",
|
||||||
|
"<foreach collection='fenceGroupIds' item='id' separator=','>",
|
||||||
|
"(#{id}, #{vehicleId})",
|
||||||
|
"</foreach>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,5 @@ public interface IFencegroupService extends IService<FenceGroup> {
|
||||||
|
|
||||||
void addGroup(FenceGroupAddReq addReq);
|
void addGroup(FenceGroupAddReq addReq);
|
||||||
|
|
||||||
// List<FenceGroup> haveFence(HaveFence haveFence);
|
|
||||||
//
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.muyu.enterprise.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
|
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||||
import com.muyu.domain.req.VehicleManageReq;
|
import com.muyu.domain.req.VehicleManageReq;
|
||||||
import com.muyu.domain.resp.VehicleManageResp;
|
import com.muyu.domain.resp.VehicleManageResp;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,4 +33,9 @@ public interface VehicleService extends IService<Vehicle> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Long findByVehicleVin(String vehicleVin);
|
Long findByVehicleVin(String vehicleVin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定围栏组
|
||||||
|
*/
|
||||||
|
void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.enterprise.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import com.muyu.enterprise.cache.FenceCahceService;
|
||||||
import com.muyu.enterprise.mapper.ElectMapper;
|
import com.muyu.enterprise.mapper.ElectMapper;
|
||||||
import com.muyu.enterprise.mapper.WarnLogsMapper;
|
import com.muyu.enterprise.mapper.WarnLogsMapper;
|
||||||
import com.muyu.enterprise.service.ElectService;
|
import com.muyu.enterprise.service.ElectService;
|
||||||
|
@ -25,6 +26,10 @@ public class ElectServiceImpl
|
||||||
@Autowired
|
@Autowired
|
||||||
private WarnLogsMapper warnLogsMapper;
|
private WarnLogsMapper warnLogsMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FenceCahceService fenceCahceService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FenceResp> selectFenceList(FenceReq req) {
|
public List<FenceResp> selectFenceList(FenceReq req) {
|
||||||
|
|
||||||
|
@ -39,6 +44,11 @@ public class ElectServiceImpl
|
||||||
req.getFenceName()
|
req.getFenceName()
|
||||||
);
|
);
|
||||||
List<FenceResp> list = electMapper.selectJoinList(FenceResp.class, wrapper);
|
List<FenceResp> list = electMapper.selectJoinList(FenceResp.class, wrapper);
|
||||||
|
|
||||||
|
String decode = fenceCahceService.decode(String.valueOf(list));
|
||||||
|
|
||||||
|
//将获取到的数据存到Redis
|
||||||
|
// fenceCahceService.put(String.valueOf(decode),d);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -41,10 +41,5 @@ public class FencegroupServiceImpl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public List<FenceGroup> haveFence(HaveFence haveFence) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@ package com.muyu.enterprise.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.enterprise.mapper.MessageValueMapper;
|
|
||||||
import com.muyu.enterprise.service.MessageValueService;
|
|
||||||
import com.muyu.domain.MessageValue;
|
import com.muyu.domain.MessageValue;
|
||||||
import com.muyu.domain.req.MessageValueReq;
|
import com.muyu.domain.req.MessageValueReq;
|
||||||
import com.muyu.domain.resp.MessageValueListResp;
|
import com.muyu.domain.resp.MessageValueListResp;
|
||||||
|
import com.muyu.enterprise.cache.AllMessageValueCacheService;
|
||||||
|
import com.muyu.enterprise.mapper.MessageValueMapper;
|
||||||
|
import com.muyu.enterprise.service.MessageValueService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -31,6 +32,9 @@ public class MessageValueServiceImpl
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageValueMapper messageValueMapper;
|
private MessageValueMapper messageValueMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AllMessageValueCacheService allMessageValueCacheService;
|
||||||
|
|
||||||
public MessageValueServiceImpl(MessageValueMapper messageValueMapper) {
|
public MessageValueServiceImpl(MessageValueMapper messageValueMapper) {
|
||||||
this.messageValueMapper = messageValueMapper;
|
this.messageValueMapper = messageValueMapper;
|
||||||
}
|
}
|
||||||
|
@ -63,11 +67,13 @@ public class MessageValueServiceImpl
|
||||||
LambdaQueryWrapper<MessageValue> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MessageValue> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(MessageValue::getTemplateId, templateId);
|
queryWrapper.eq(MessageValue::getTemplateId, templateId);
|
||||||
List<MessageValue> list = this.list(queryWrapper);
|
List<MessageValue> list = this.list(queryWrapper);
|
||||||
return list.stream()
|
List<MessageValueListResp> collect = list.stream()
|
||||||
.map(messageValue -> MessageValueListResp.valueBuild(
|
.map(messageValue -> MessageValueListResp.valueBuild(
|
||||||
messageValue
|
messageValue
|
||||||
)
|
)
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
|
allMessageValueCacheService.put(String.valueOf(templateId), collect);
|
||||||
|
return collect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,10 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
import com.muyu.domain.VehicleType;
|
import com.muyu.domain.VehicleType;
|
||||||
|
import com.muyu.domain.req.BoundFenceGroupReq;
|
||||||
import com.muyu.domain.req.VehicleManageReq;
|
import com.muyu.domain.req.VehicleManageReq;
|
||||||
import com.muyu.domain.resp.VehicleManageResp;
|
import com.muyu.domain.resp.VehicleManageResp;
|
||||||
|
import com.muyu.enterprise.cache.AllVehicleCacheService;
|
||||||
import com.muyu.enterprise.mapper.VehicleMapper;
|
import com.muyu.enterprise.mapper.VehicleMapper;
|
||||||
import com.muyu.enterprise.service.VehicleService;
|
import com.muyu.enterprise.service.VehicleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -69,4 +71,11 @@ public class VehicleServiceImpl
|
||||||
return templateId;
|
return templateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void boundFenceGroup(BoundFenceGroupReq boundFenceGroupReq) {
|
||||||
|
|
||||||
|
vehicleMapper.boundFenceGroup(boundFenceGroupReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -100,6 +100,13 @@
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
<artifactId>cloud-common-kafka</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--缓存依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -116,6 +116,12 @@
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
<artifactId>cloud-common-kafka</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.cloud.protocol.parsing.feign;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.domain.resp.MessageValueListResp;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: LiDongJia
|
|
||||||
* @Package: com.muyu.cloud.protocol.parsing.feign
|
|
||||||
* @Project: 2112-car-cloud-server
|
|
||||||
* @name: RemoteServiceClient
|
|
||||||
* @Date: 2024/9/28 14:49
|
|
||||||
* @Description: 远程调用接口
|
|
||||||
*/
|
|
||||||
@FeignClient(name = "cloud-car")
|
|
||||||
public interface RemoteServiceClient {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过车辆vin码查询模板id
|
|
||||||
* @param vehicleVin
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/vehicleManage/findByVehicleVin/{vehicleVin}")
|
|
||||||
@Operation(description = "通过车辆vin码查询模板id")
|
|
||||||
public Result<Long> findByVehicleVin(@PathVariable("vehicleVin") String vehicleVin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据报文模版id查询报文数据
|
|
||||||
* @param templateId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/messageValue/findByTemplateId/{templateId}")
|
|
||||||
@Operation(summary = "根据报文模版id查询报文数据", description = "根据报文模版id查询报文数据")
|
|
||||||
public Result<List<MessageValueListResp>> findByTemplateId(@PathVariable("templateId") Long templateId);
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.cloud.protocol.parsing.feign.factory;
|
|
||||||
|
|
||||||
import com.muyu.cloud.protocol.parsing.feign.RemoteServiceClient;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.domain.resp.MessageValueListResp;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 报文模版对象服务降级处理
|
|
||||||
* @Author:李庆帅
|
|
||||||
* @Package:com.muyu.analysis.parsing.remote.factory
|
|
||||||
* @Project:cloud-server
|
|
||||||
* @name:RemoteServiceClientFactory
|
|
||||||
* @Date:2024/9/28 21:16
|
|
||||||
*/
|
|
||||||
public class RemoteServiceClientFactory implements FallbackFactory<RemoteServiceClient>
|
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(com.muyu.cloud.protocol.parsing.feign.factory.RemoteServiceClientFactory.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RemoteServiceClient create(Throwable throwable) {
|
|
||||||
log.error("报文模版传参调用失败:{}", throwable.getMessage());
|
|
||||||
return new RemoteServiceClient() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Long> findByVehicleVin(String vehicleVin) {
|
|
||||||
return Result.success(Long.valueOf(vehicleVin));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<MessageValueListResp>> findByTemplateId(Long templateId) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +1,17 @@
|
||||||
package com.muyu.cloud.protocol.parsing.test;
|
package com.muyu.cloud.protocol.parsing.test;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.muyu.domain.Vehicle;
|
||||||
import com.muyu.cloud.protocol.parsing.feign.RemoteServiceClient;
|
import com.muyu.domain.VehicleType;
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.domain.resp.MessageValueListResp;
|
import com.muyu.domain.resp.MessageValueListResp;
|
||||||
|
import com.muyu.enterprise.cache.AllMessageValueCacheService;
|
||||||
|
import com.muyu.enterprise.cache.VehicleCacheService;
|
||||||
|
import com.muyu.enterprise.cache.VehicleTypeCacheService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
@ -27,17 +28,20 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
public class ParsingTest {
|
public class ParsingMessage {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteServiceClient remoteServiceClient;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private KafkaProducer<String, String> kafkaProducer;
|
private KafkaProducer<String, String> kafkaProducer;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleCacheService vehicleCacheService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleTypeCacheService vehicleTypeCacheService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AllMessageValueCacheService allMessageValueCacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议解析
|
* 协议解析
|
||||||
*/
|
*/
|
||||||
|
@ -92,32 +96,34 @@ public class ParsingTest {
|
||||||
String vehicleVin = result.substring(1, 18);
|
String vehicleVin = result.substring(1, 18);
|
||||||
log.info("车辆VIN码: " + vehicleVin);
|
log.info("车辆VIN码: " + vehicleVin);
|
||||||
//根据车辆VIN码查询报文模板ID
|
//根据车辆VIN码查询报文模板ID
|
||||||
Result<Long> byVehicleVin = remoteServiceClient.findByVehicleVin(vehicleVin);
|
Vehicle vehicle = vehicleCacheService.get(vehicleVin);
|
||||||
Long templateId = byVehicleVin.getData();
|
Long vehicleTypeId = vehicle.getVehicleTypeId();
|
||||||
List<MessageValueListResp> templateList;
|
VehicleType vehicleType = vehicleTypeCacheService.get(String.valueOf(vehicleTypeId));
|
||||||
//从redis缓存中获取报文模板数据
|
Long templateId = vehicleType.getMessageTemplateId();
|
||||||
try {
|
List<MessageValueListResp> templateList = allMessageValueCacheService.get(String.valueOf(templateId));
|
||||||
String redisKey = "messageTemplate" + templateId;
|
// //从redis缓存中获取报文模板数据
|
||||||
if (redisTemplate.hasKey(redisKey)) {
|
// try {
|
||||||
List<Object> list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
// String redisKey = "messageTemplate" + templateId;
|
||||||
templateList = list.stream()
|
// if (redisTemplate.hasKey(redisKey)) {
|
||||||
.map(obj -> JSON.parseObject(obj.toString(), MessageValueListResp.class))
|
// List<Object> list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
||||||
.toList();
|
// templateList = list.stream()
|
||||||
log.info("Redis缓存查询成功");
|
// .map(obj -> JSON.parseObject(obj.toString(), MessageValueListResp.class))
|
||||||
} else {
|
// .toList();
|
||||||
Result<List<MessageValueListResp>> byTemplateId = remoteServiceClient.findByTemplateId(templateId);
|
// log.info("Redis缓存查询成功");
|
||||||
templateList = byTemplateId.getData();
|
// } else {
|
||||||
templateList.forEach(
|
// Result<List<MessageValueListResp>> byTemplateId = remoteServiceClient.findByTemplateId(templateId);
|
||||||
listResp ->
|
// templateList = byTemplateId.getData();
|
||||||
redisTemplate.opsForList().rightPush(
|
// templateList.forEach(
|
||||||
redisKey, JSON.toJSONString(listResp)
|
// listResp ->
|
||||||
)
|
// redisTemplate.opsForList().rightPush(
|
||||||
);
|
// redisKey, JSON.toJSONString(listResp)
|
||||||
log.info("数据库查询成功");
|
// )
|
||||||
}
|
// );
|
||||||
} catch (Exception e) {
|
// log.info("数据库查询成功");
|
||||||
throw new RuntimeException("获取报文模板失败");
|
// }
|
||||||
}
|
// } catch (Exception e) {
|
||||||
|
// throw new RuntimeException("获取报文模板失败");
|
||||||
|
// }
|
||||||
//判断报文模板列表不为空
|
//判断报文模板列表不为空
|
||||||
if (templateList.isEmpty()) {
|
if (templateList.isEmpty()) {
|
||||||
throw new RuntimeException("报文模版为空");
|
throw new RuntimeException("报文模版为空");
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -95,26 +95,31 @@
|
||||||
<version>${mqtt.version}</version>
|
<version>${mqtt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>ecs20140526</artifactId>
|
<artifactId>ecs20140526</artifactId>
|
||||||
<version>5.1.8</version>
|
<version>5.1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>tea-openapi</artifactId>
|
<artifactId>tea-openapi</artifactId>
|
||||||
<version>0.3.2</version>
|
<version>0.3.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>tea-console</artifactId>
|
<artifactId>tea-console</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>tea-util</artifactId>
|
<artifactId>tea-util</artifactId>
|
||||||
<version>0.2.21</version>
|
<version>0.2.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>darabonba-env</artifactId>
|
||||||
|
<version>0.1.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.muyu.cloud.vehicle.gateway.aliyun.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Instance {
|
||||||
|
|
||||||
|
private String instanceId;
|
||||||
|
|
||||||
|
private String ipAddress;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
}
|
|
@ -1,23 +1,36 @@
|
||||||
// This file is auto-generated, don't edit it. Thanks.
|
// This file is auto-generated, don't edit it. Thanks.
|
||||||
package com.muyu.cloud.vehicle.gateway.test.example;
|
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.ecs20140526.models.DeleteInstancesRequest;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||||
import com.aliyun.tea.*;
|
import com.aliyun.tea.*;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.event.ContextClosedEvent;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除实例
|
* 删除实例
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
public class DelInstance implements DisposableBean{
|
public class DelInstance implements ApplicationListener<ContextClosedEvent> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>description</b> :
|
* <b>description</b> :
|
||||||
|
@ -26,46 +39,48 @@ public class DelInstance implements DisposableBean{
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
public static Client createClient() throws Exception {
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
Config config = new Config()
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
return new Client(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void delInstance() throws Exception{
|
public void delInstance() throws Exception{
|
||||||
//创建ECS客户端对象,用于后续调用ECS相关API
|
//创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
com.aliyun.ecs20140526.Client client = DelInstance.createClient();
|
Client client = DelInstance.createClient();
|
||||||
|
|
||||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
List<String> list = redisTemplate.opsForList().range("instanceIds",0,-1);
|
||||||
.setRegionId("cn-shanghai");
|
|
||||||
|
|
||||||
//创建运行时选择对象,用于配置运行时的选项参数
|
// DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||||
RuntimeOptions runtimeOptions = new RuntimeOptions();
|
// .setRegionId("cn-shanghai");
|
||||||
|
|
||||||
//获取实例列表
|
// //创建运行时选择对象,用于配置运行时的选项参数
|
||||||
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
// RuntimeOptions runtimeOptions = new RuntimeOptions();
|
||||||
|
//
|
||||||
//提取实例ID集合
|
// //获取实例列表
|
||||||
ArrayList<String> list = new ArrayList<>();
|
// DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
||||||
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
//
|
||||||
|
// //提取实例ID集合
|
||||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
// ArrayList<String> list = new ArrayList<>();
|
||||||
list.add(instance.getInstanceId());
|
// DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||||
}
|
//
|
||||||
|
// for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
||||||
System.out.println("Instance IDs"+list);
|
// list.add(instance.getInstanceId());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// System.out.println("Instance IDs"+list);
|
||||||
|
|
||||||
// 创建删除实例请求对象,并设置请求参数
|
// 创建删除实例请求对象,并设置请求参数
|
||||||
com.aliyun.ecs20140526.models.DeleteInstancesRequest deleteInstancesRequest = new com.aliyun.ecs20140526.models.DeleteInstancesRequest()
|
DeleteInstancesRequest deleteInstancesRequest = new DeleteInstancesRequest()
|
||||||
// 设置地域ID,指定要删除的实例所属的地域ID。
|
// 设置地域ID,指定要删除的实例所属的地域ID。
|
||||||
.setRegionId("cn-shanghai")
|
.setRegionId("cn-shanghai")
|
||||||
//设置DryRun为True,用于验证请求是否可以成功,但不实际执行删除操作
|
//设置DryRun为True,用于验证请求是否可以成功,但不实际执行删除操作
|
||||||
|
@ -77,32 +92,44 @@ public class DelInstance implements DisposableBean{
|
||||||
// 设置实例ID列表,使用参数名称 instanceId,参数类型为数组。
|
// 设置实例ID列表,使用参数名称 instanceId,参数类型为数组。
|
||||||
.setInstanceId(list);
|
.setInstanceId(list);
|
||||||
// 创建运行时选项对象,用于配置运行时的选项参数
|
// 创建运行时选项对象,用于配置运行时的选项参数
|
||||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
try{
|
try{
|
||||||
//复制代码运行请自行打印 API 的返回值
|
//复制代码运行请自行打印 API 的返回值
|
||||||
client.deleteInstancesWithOptions(deleteInstancesRequest,runtime);
|
client.deleteInstancesWithOptions(deleteInstancesRequest,runtime);
|
||||||
} catch (TeaException error) {
|
} catch (TeaException error) {
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
// 错误 message
|
// 错误 message
|
||||||
System.out.println(error.getMessage());
|
log.error(error.getMessage());
|
||||||
// 诊断地址
|
// 诊断地址
|
||||||
System.out.println(error.getData().get("Recommend"));
|
log.error(error.getData().get("Recommend"));
|
||||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
Common.assertAsString(error.message);
|
||||||
} catch (Exception _error){
|
} catch (Exception _error){
|
||||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
// 错误 message
|
// 错误 message
|
||||||
System.out.println(error.getMessage());
|
log.error(error.getMessage());
|
||||||
//诊断地址
|
// 诊断地址
|
||||||
System.out.println(error.getData().get("Recommend"));
|
log.error(error.getData().get("Recommend"));
|
||||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
Common.assertAsString(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void destroy() throws Exception {
|
||||||
|
// log.info("===============>开始执行删除实例方法");
|
||||||
|
// delInstance();
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void onApplicationEvent(ContextClosedEvent event) {
|
||||||
log.info("===============>开始执行删除实例方法");
|
try{
|
||||||
delInstance();
|
log.info("=======>删除实例");
|
||||||
|
delInstance();
|
||||||
|
redisTemplate.delete("instanceIds");
|
||||||
|
redisTemplate.delete("instanceList");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import com.aliyun.darabonba.env.EnvClient;
|
||||||
|
import com.aliyun.teautil.Common;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询一台或多台实例的详细信息
|
||||||
|
*/
|
||||||
|
public class QueryInstance {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>description</b> :
|
||||||
|
* <p>使用AK&SK初始化账号Client</p>
|
||||||
|
* @return Client
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Client createClient(String alibabaCloudAccessKeyId, String alibabaCloudAccessKeySecret) throws Exception{
|
||||||
|
Config config = new Config()
|
||||||
|
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
||||||
|
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
||||||
|
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
||||||
|
return new Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Client createClientWithSTS() throws Exception {
|
||||||
|
Config config = new Config()
|
||||||
|
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
||||||
|
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN")
|
||||||
|
.setSecurityToken("token")
|
||||||
|
.setType("sts");
|
||||||
|
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
||||||
|
return new Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args_) throws Exception{
|
||||||
|
List<String> list = Arrays.asList(args_);
|
||||||
|
|
||||||
|
Client client = QueryInstance.createClient(EnvClient.getEnv("LTAI5t7Fnx2QLTYLSu9357wP"), EnvClient.getEnv("3LOnydNZ25ytsTGczuSygElx0HJ6nN"));
|
||||||
|
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||||
|
.setRegionId("cn-shanghai")
|
||||||
|
.setInternetChargeType("PayByTraffic")
|
||||||
|
.setInstanceChargeType("PostPaid");
|
||||||
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
|
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||||
|
com.aliyun.teaconsole.Client.log(Common.toJSONString(resp));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,25 @@
|
||||||
package com.muyu.cloud.vehicle.gateway.test.example;
|
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
|
||||||
|
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.ecs20140526.models.*;
|
||||||
import com.aliyun.tea.*;
|
import com.aliyun.tea.*;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import com.muyu.cloud.vehicle.gateway.aliyun.domain.Instance;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.apache.logging.log4j.CloseableThreadContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.data.redis.core.ListOperations;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量创建ECS实例
|
* 批量创建ECS实例
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +27,11 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class Sample implements ApplicationRunner {
|
public class Sample implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>description</b> :
|
* <b>description</b> :
|
||||||
* <p>使用AK&SK初始化账号Client</p>
|
* <p>使用AK&SK初始化账号Client</p>
|
||||||
|
@ -21,44 +39,51 @@ public class Sample implements ApplicationRunner {
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
public static Client createClient() throws Exception {
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
Config config = new Config()
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
return new Client(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void creatInstance() throws Exception {
|
public void creatInstance() throws Exception {
|
||||||
|
|
||||||
// 将命令行参数转换为字符串列表
|
// 将命令行参数转换为字符串列表
|
||||||
java.util.List<String> args = java.util.Arrays.asList();
|
List<String> args = Arrays.asList();
|
||||||
// 创建阿里云ECS客户端
|
// 创建阿里云ECS客户端
|
||||||
com.aliyun.ecs20140526.Client client = Sample.createClient();
|
Client client = Sample.createClient();
|
||||||
// 配置系统盘参数
|
// 配置系统盘参数
|
||||||
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
|
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||||
.setSize("20")// 设置系统盘大小为40GB
|
.setSize("20")// 设置系统盘大小为40GB
|
||||||
.setCategory("cloud_essd");// 设置系统盘类型为cloud_essd
|
.setCategory("cloud_essd");// 设置系统盘类型为cloud_essd
|
||||||
// 创建创建实例请求对象并设置参数
|
// 创建创建实例请求对象并设置参数
|
||||||
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
|
RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
|
||||||
.setRegionId("cn-shanghai") // 设置地域ID
|
.setRegionId("cn-shanghai") // 设置地域ID
|
||||||
.setImageId("m-uf66taa8r57hvow8cxlj")// 设置镜像ID
|
.setImageId("m-uf63dnbv4od71jlezdne")// 设置镜像ID
|
||||||
.setInstanceType("ecs.e-c1m1.large")// 设置实例类型
|
.setInstanceType("ecs.e-c1m1.large")// 设置实例类型
|
||||||
.setSecurityGroupId("sg-uf6hyictocodexptlgiv")// 设置安全组ID
|
.setSecurityGroupId("sg-uf6hyictocodexptlgiv")// 设置安全组ID
|
||||||
.setVSwitchId("vsw-uf6ags5luz17qd6ckn2tb")// 设置虚拟交换机ID
|
.setVSwitchId("vsw-uf6ags5luz17qd6ckn2tb")// 设置虚拟交换机ID
|
||||||
.setInstanceName("launch-advisor-20240928")// 设置实例名称
|
.setInstanceName("launch-advisor-20240929")// 设置实例名称
|
||||||
.setInstanceChargeType("PostPaid")// 设置实例付费类型为后付费按量付费
|
.setInstanceChargeType("PostPaid")// 设置实例付费类型为后付费按量付费
|
||||||
.setSystemDisk(systemDisk)// 设置系统盘配置
|
.setSystemDisk(systemDisk)// 设置系统盘配置
|
||||||
.setHostName("root")// 设置主机名
|
.setHostName("root")// 设置主机名
|
||||||
.setPassword("@ywt021900")// 设置实例密码
|
.setPassword("@ywt021900")// 设置实例密码
|
||||||
.setAmount(2);// 设置创建实例的数量
|
.setAmount(1)// 设置创建实例的数量
|
||||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
.setInternetChargeType("PayByTraffic")// 设置互联网计费类型为按流量计费
|
||||||
|
.setInternetMaxBandwidthOut(1);// 设置互联网最大出带宽为1 Mbps
|
||||||
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
try {
|
try {
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
client.runInstancesWithOptions(runInstancesRequest, runtime);
|
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||||
|
RunInstancesResponseBody body = runInstancesResponse.getBody();
|
||||||
|
ArrayList<String> list = new ArrayList<>(body.getInstanceIdSets().getInstanceIdSet());
|
||||||
|
log.info("实例ID:{}", list);
|
||||||
|
|
||||||
} catch (TeaException error) {
|
} catch (TeaException error) {
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
// 错误 message
|
// 错误 message
|
||||||
|
@ -77,6 +102,13 @@ public class Sample implements ApplicationRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private static DescribeInstancesResponse queryInstanceDetails(Client client) {
|
||||||
|
//
|
||||||
|
// //创建查询实例请求对象并设置参数
|
||||||
|
// DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
log.info("===============>开始批量创建实例");
|
log.info("===============>开始批量创建实例");
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;//// This file is auto-generated, don't edit it. Thanks.
|
||||||
|
//package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
|
||||||
|
//
|
||||||
|
//import com.aliyun.tea.*;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * 启动一台实例
|
||||||
|
// */
|
||||||
|
//public class StartInstance {
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * <b>description</b> :
|
||||||
|
// * <p>使用AK&SK初始化账号Client</p>
|
||||||
|
// * @return Client
|
||||||
|
// *
|
||||||
|
// * @throws Exception
|
||||||
|
// */
|
||||||
|
// public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
||||||
|
// // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
|
// // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
|
// com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
|
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
|
// .setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
||||||
|
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
|
// .setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
||||||
|
// // Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
|
// config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
||||||
|
// return new com.aliyun.ecs20140526.Client(config);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void main(String[] args_) throws Exception {
|
||||||
|
// java.util.List<String> args = java.util.Arrays.asList(args_);
|
||||||
|
// com.aliyun.ecs20140526.Client client = StartInstance.createClient();
|
||||||
|
// com.aliyun.ecs20140526.models.StartInstanceRequest startInstanceRequest = new com.aliyun.ecs20140526.models.StartInstanceRequest();
|
||||||
|
// com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
// try {
|
||||||
|
// // 复制代码运行请自行打印 API 的返回值
|
||||||
|
// client.startInstanceWithOptions(startInstanceRequest, runtime);
|
||||||
|
// } catch (TeaException error) {
|
||||||
|
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// // 错误 message
|
||||||
|
// System.out.println(error.getMessage());
|
||||||
|
// // 诊断地址
|
||||||
|
// System.out.println(error.getData().get("Recommend"));
|
||||||
|
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
// } catch (Exception _error) {
|
||||||
|
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// // 错误 message
|
||||||
|
// System.out.println(error.getMessage());
|
||||||
|
// // 诊断地址
|
||||||
|
// System.out.println(error.getData().get("Recommend"));
|
||||||
|
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -1,56 +0,0 @@
|
||||||
// This file is auto-generated, don't edit it. Thanks.
|
|
||||||
package com.muyu.cloud.vehicle.gateway.test.example;
|
|
||||||
|
|
||||||
import com.aliyun.tea.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动一台实例
|
|
||||||
*/
|
|
||||||
public class StartInstance {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <b>description</b> :
|
|
||||||
* <p>使用AK&SK初始化账号Client</p>
|
|
||||||
* @return Client
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
|
||||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
|
||||||
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
|
||||||
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
|
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
|
||||||
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args_) throws Exception {
|
|
||||||
java.util.List<String> args = java.util.Arrays.asList(args_);
|
|
||||||
com.aliyun.ecs20140526.Client client = StartInstance.createClient();
|
|
||||||
com.aliyun.ecs20140526.models.StartInstanceRequest startInstanceRequest = new com.aliyun.ecs20140526.models.StartInstanceRequest();
|
|
||||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
|
||||||
try {
|
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
|
||||||
client.startInstanceWithOptions(startInstanceRequest, runtime);
|
|
||||||
} catch (TeaException error) {
|
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
|
||||||
// 错误 message
|
|
||||||
System.out.println(error.getMessage());
|
|
||||||
// 诊断地址
|
|
||||||
System.out.println(error.getData().get("Recommend"));
|
|
||||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
|
||||||
} catch (Exception _error) {
|
|
||||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
|
||||||
// 错误 message
|
|
||||||
System.out.println(error.getMessage());
|
|
||||||
// 诊断地址
|
|
||||||
System.out.println(error.getData().get("Recommend"));
|
|
||||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.49.53:8848
|
addr: 47.101.49.53:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: seven
|
namespace: vehicle
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
Loading…
Reference in New Issue