模拟直连设备在APP注册接入
This commit is contained in:
@@ -23,16 +23,6 @@
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>access-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>algorithm-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-system-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -40,6 +30,34 @@
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-device-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.access;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.conf.EnableMPP;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -17,7 +16,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@EnableFeignClients(basePackages = "com.njcn")
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
@EnableMPP
|
||||
public class AccessBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.njcn.access.config;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.OAuthBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/3 9:03
|
||||
*/
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Value("${microservice.gateway.url}")
|
||||
private String gatewayUrl;
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
|
||||
List<GrantType> grantTypes = new ArrayList<>();
|
||||
String passwordTokenUrl = "http://" + gatewayUrl + "/pqs-auth/oauth/token";
|
||||
ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl);
|
||||
grantTypes.add(resourceOwnerPasswordCredentialsGrant);
|
||||
OAuth oAuth = new OAuthBuilder().name("oauth2").grantTypes(grantTypes).build();
|
||||
//schemas
|
||||
List<SecurityScheme> securitySchemes = Lists.newArrayList(oAuth);
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("物联网注册服务")
|
||||
.apiInfo(apiInfo())
|
||||
.enable(true)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.njcn.access.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securityContexts(securityContexts())
|
||||
.securitySchemes(securitySchemes);
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("物接入")
|
||||
.description("物接入接口文档")
|
||||
.version("1.0")
|
||||
.contact(contact())
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.forPaths(PathSelectors.ant("/**"))
|
||||
.build());
|
||||
return securityContexts;
|
||||
}
|
||||
|
||||
List<SecurityReference> defaultAuth() {
|
||||
//scope方位
|
||||
List<AuthorizationScope> scopes = new ArrayList<>();
|
||||
scopes.add(new AuthorizationScope("read", "read resources"));
|
||||
scopes.add(new AuthorizationScope("write", "write resources"));
|
||||
scopes.add(new AuthorizationScope("reads", "read all resources"));
|
||||
scopes.add(new AuthorizationScope("writes", "write all resources"));
|
||||
SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[]{}));
|
||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||
securityReferences.add(securityReference);
|
||||
return securityReferences;
|
||||
}
|
||||
|
||||
private Contact contact() {
|
||||
return new Contact("灿能系统组", "", "13914774158@163.com");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/16 13:58
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/devAccess")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "装置接入")
|
||||
public class AccessController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +1,21 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.service.IDevModelService;
|
||||
import com.njcn.access.service.ICsDevModelService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -23,27 +24,26 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 10:26
|
||||
* @createTime 2023/7/3 15:31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/devModel")
|
||||
@RequestMapping("/analyzeModel")
|
||||
@Api(tags = "模板解析")
|
||||
@AllArgsConstructor
|
||||
@Validated
|
||||
@Api(tags = "装置模板录入")
|
||||
public class DevModelController extends BaseController {
|
||||
public class CsDevModelController extends BaseController {
|
||||
|
||||
private final IDevModelService devModelService;
|
||||
private final ICsDevModelService csDevModelService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("装置录入模板")
|
||||
public HttpResult<String> add(DevModelParam devModelParam){
|
||||
log.info("装置录入模板文件");
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},装置录入模板文件", methodDescribe);
|
||||
devModelService.add(devModelParam);
|
||||
@PostMapping("/addModel")
|
||||
@ApiOperation("新增设备模板")
|
||||
@ApiImplicitParam(name = "devModelParam", value = "设备模板参数", required = true)
|
||||
public HttpResult<String> addModel(@RequestBody @Validated DevModelParam devModelParam){
|
||||
String methodDescribe = getMethodDescribe("addModel");
|
||||
csDevModelService.addModel(devModelParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
import com.njcn.access.service.ICsDeviceService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/4 11:23
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/device")
|
||||
@Api(tags = "设备注册接入")
|
||||
@AllArgsConstructor
|
||||
@Validated
|
||||
public class CsDeviceController extends BaseController {
|
||||
|
||||
private final ICsDeviceService csDeviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/register")
|
||||
@ApiOperation("设备注册")
|
||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||
public HttpResult<String> devRegister(@RequestParam String nDid){
|
||||
csDeviceService.devRegister(nDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "设备MQTT通讯状态!");
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/model")
|
||||
@ApiOperation("获取装置模板信息")
|
||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||
public HttpResult<Object> getModel(@RequestParam String nDid){
|
||||
String methodDescribe = getMethodDescribe("getModel");
|
||||
Object object = csDeviceService.getModel(nDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, object, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/access")
|
||||
@ApiOperation("设备接入")
|
||||
@ApiImplicitParam(name = "devAccessParam", value = "接入参数", required = true)
|
||||
public HttpResult<String> devAccess(@RequestBody @Validated DevAccessParam devAccessParam){
|
||||
String methodDescribe = getMethodDescribe("getModel");
|
||||
csDeviceService.devAccess(devAccessParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.njcn.access.controller;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@@ -11,18 +11,20 @@ import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 前端控制器
|
||||
* 监测点模板表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csNetDev")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "网关管理")
|
||||
@Slf4j
|
||||
public class CsNetDevController extends BaseController {
|
||||
@RestController
|
||||
@RequestMapping("/csLineModel")
|
||||
@Api(tags = "监测点模板")
|
||||
@AllArgsConstructor
|
||||
public class CsLineModelController extends BaseController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.access.pojo.MessageParam;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/18 13:53
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
@Api(value = "TestController", tags = {"测试 API"})
|
||||
public class KafkaController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
@PostMapping("/kafka/sendMessage")
|
||||
@ApiOperation(value = "发送kafka告警消息")
|
||||
public void sendKafkaMessage(@Valid @ApiParam("参数") @RequestBody MessageParam param) {
|
||||
kafkaTemplate.send(param.getTopic(), param.getMessage());
|
||||
}
|
||||
|
||||
@Component
|
||||
public class KafkaConsumer {
|
||||
// 消费监听
|
||||
@KafkaListener(topics = {"topic2"})
|
||||
public void onMessage1(ConsumerRecord<?, ?> record){
|
||||
// 消费的哪个topic、partition的消息,打印出消息内容
|
||||
System.out.println("简单消费:"+record.topic()+"-"+record.partition()+"-"+record.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.njcn.access.controller;
|
||||
//
|
||||
//import com.njcn.access.pojo.param.MessageParam;
|
||||
//import com.njcn.web.controller.BaseController;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import io.swagger.annotations.ApiParam;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
//import org.springframework.kafka.annotation.KafkaListener;
|
||||
//import org.springframework.kafka.core.KafkaTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import javax.validation.Valid;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/4/18 13:53
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/test")
|
||||
//@Api(value = "TestController", tags = {"测试 API"})
|
||||
//public class KafkaController extends BaseController {
|
||||
//
|
||||
// @Resource
|
||||
// private KafkaTemplate<String, String> kafkaTemplate;
|
||||
//
|
||||
// @PostMapping("/kafka/sendMessage")
|
||||
// @ApiOperation(value = "发送kafka告警消息")
|
||||
// public void sendKafkaMessage(@Valid @ApiParam("参数") @RequestBody MessageParam param) {
|
||||
// kafkaTemplate.send(param.getTopic(), param.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Component
|
||||
// public class KafkaConsumer {
|
||||
// // 消费监听
|
||||
// @KafkaListener(topics = {"topic2"})
|
||||
// public void onMessage1(ConsumerRecord<?, ?> record){
|
||||
// // 消费的哪个topic、partition的消息,打印出消息内容
|
||||
// System.out.println("简单消费:"+record.topic()+"-"+record.partition()+"-"+record.value());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.service.IAccessService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/3/31 9:12
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/devRegister")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "装置注册")
|
||||
public class RegisterController extends BaseController {
|
||||
|
||||
private final IAccessService accessService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("平台发起注册")
|
||||
@ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
|
||||
public HttpResult<Object> add(@RequestParam String nDid){
|
||||
log.info("设备向装置侧发起注册请求,请求的nDid为:" + nDid);
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},设备向装置侧发起注册请求,请求的nDid为:{}", methodDescribe, nDid);
|
||||
accessService.add(nDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/12 10:28
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/topic")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "装置主题")
|
||||
public class TopicController extends BaseController {
|
||||
|
||||
private final ICsTopicService csTopicService;
|
||||
|
||||
@PostMapping("/ask")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("平台询问装置支持主题")
|
||||
@ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
|
||||
public HttpResult<Object> ask(@RequestParam String nDid){
|
||||
String methodDescribe = getMethodDescribe("ask");
|
||||
LogUtil.njcnDebug(log, "{},平台询问装置支持主题,请求的nDid为:{}", methodDescribe, nDid);
|
||||
csTopicService.askDevTopic(nDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.access.handler;
|
||||
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||
@@ -10,22 +11,17 @@ import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.DevModInfoDto;
|
||||
import com.njcn.access.pojo.dto.ModelDto;
|
||||
import com.njcn.access.pojo.dto.TopicDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.dto.heart.HeartBeatDto;
|
||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||
import com.njcn.access.pojo.po.CsTopicPO;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.algorithm.api.DevModelFeignClient;
|
||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
|
||||
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
|
||||
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
import com.njcn.access.service.ICsLineModelService;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
@@ -33,11 +29,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validator;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -49,52 +45,52 @@ import java.util.*;
|
||||
@AllArgsConstructor
|
||||
public class MqttMessageHandler {
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final ICsLineModelService csLineModelService;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final ICsTopicService csTopicService;
|
||||
|
||||
@Autowired
|
||||
Validator validator;
|
||||
|
||||
@MqttSubscribe(value = "/Dev/Topic/{edgeId}",qos = 1)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void devTopic(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||
Gson gson = new Gson();
|
||||
ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
||||
//检验传递的参数是否准确
|
||||
Set<ConstraintViolation<ReqAndResParam.Res>> validate = validator.validate(res);
|
||||
validate.forEach(constraintViolation -> {
|
||||
System.out.println(constraintViolation.getMessage());
|
||||
});
|
||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
if (Objects.equals(res.getType(), TypeEnum.TYPE_1.getCode())){
|
||||
List<CsTopicPO> list = new ArrayList<>();
|
||||
//fixme 这边获取数据需要调整
|
||||
Map<String,List<String>> map = (Map<String,List<String>>)res.getMsg();
|
||||
List<String> topicList = map.get("Topic");
|
||||
topicList.forEach(item->{
|
||||
CsTopicPO csTopicPo = new CsTopicPO();
|
||||
csTopicPo.setNdid(nDid);
|
||||
csTopicPo.setTopic(item);
|
||||
csTopicPo.setType(0);
|
||||
list.add(csTopicPo);
|
||||
});
|
||||
csTopicService.addList(list);
|
||||
} else {
|
||||
log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
// @MqttSubscribe(value = "/Dev/Topic/{edgeId}",qos = 1)
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void devTopic(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||
// Gson gson = new Gson();
|
||||
// ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
||||
// //检验传递的参数是否准确
|
||||
// Set<ConstraintViolation<ReqAndResParam.Res>> validate = validator.validate(res);
|
||||
// validate.forEach(constraintViolation -> {
|
||||
// System.out.println(constraintViolation.getMessage());
|
||||
// });
|
||||
// if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
// if (Objects.equals(res.getType(), TypeEnum.TYPE_1.getCode())){
|
||||
// List<CsTopicPO> list = new ArrayList<>();
|
||||
// //fixme 这边获取数据需要调整
|
||||
// Map<String,List<String>> map = (Map<String,List<String>>)res.getMsg();
|
||||
// List<String> topicList = map.get("Topic");
|
||||
// topicList.forEach(item->{
|
||||
// CsTopicPO csTopicPo = new CsTopicPO();
|
||||
// csTopicPo.setNdid(nDid);
|
||||
// csTopicPo.setTopic(item);
|
||||
// csTopicPo.setType(0);
|
||||
// list.add(csTopicPo);
|
||||
// });
|
||||
// csTopicService.addList(list);
|
||||
// } else {
|
||||
// log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage());
|
||||
// }
|
||||
// } else {
|
||||
// log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 装置注册应答
|
||||
@@ -108,31 +104,26 @@ public class MqttMessageHandler {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void devOperation(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||
log.info("收到注册应答响应--->" + nDid);
|
||||
//这边用redis缓存来判断是否接收响应
|
||||
redisUtil.saveByKeyWithExpire(nDid,true,5L);
|
||||
Gson gson = new Gson();
|
||||
ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
||||
//检验传递的参数是否准确
|
||||
Set<ConstraintViolation<ReqAndResParam.Res>> validate = validator.validate(res);
|
||||
validate.forEach(constraintViolation -> {
|
||||
System.out.println(constraintViolation.getMessage());
|
||||
});
|
||||
ReqAndResDto.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class);
|
||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
if (Objects.equals(res.getType(),TypeEnum.TYPE_17.getCode())){
|
||||
equipmentFeignClient.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode());
|
||||
//询问模板数据
|
||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setDid("0");
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(TypeEnum.TYPE_3.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
publisher.send("/Pfm/DevCmd/V1/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
||||
//这边用redis缓存来判断是否接收响应
|
||||
redisUtil.saveByKey(nDid,AccessEnum.SUCCESS.getCode());
|
||||
} else {
|
||||
log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage());
|
||||
log.info(AccessResponseEnum.REGISTER_RESPONSE_ERROR.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,50 +142,31 @@ public class MqttMessageHandler {
|
||||
public void devModelOperation(String topic, MqttMessage message, @NamedValue("version") String version, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||
Gson gson = new Gson();
|
||||
ModelDto modelDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ModelDto.class);
|
||||
HttpResult<CsEquipmentDeliveryVO> pojo = equipmentFeignClient.queryEquipmentByndid(nDid);
|
||||
if (!Objects.isNull(pojo)){
|
||||
String devType = pojo.getData().getDevModel();
|
||||
String dictCode = dicDataFeignClient.getDicDataById(devType).getData().getCode();
|
||||
//直连设备处理
|
||||
if (Objects.equals(dictCode, DicDataEnum.CONNECT_DEV.getCode())){
|
||||
List<DevModInfoDto> list = modelDto.getDevMod();
|
||||
list.forEach(item->{
|
||||
DictData dicData = dicDataFeignClient.getDicDataByCode(item.getDevType()).getData();
|
||||
CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
|
||||
if (Objects.isNull(dicData)) {
|
||||
log.info(AccessResponseEnum.DEV_TYPE_NOT_FIND.getMessage());
|
||||
return;
|
||||
} else {
|
||||
csDevModelQueryListParm.setDevType(dicData.getId());
|
||||
}
|
||||
csDevModelQueryListParm.setVersionNo(item.getVersionNo());
|
||||
csDevModelQueryListParm.setVersionDate(item.getVersionDate());
|
||||
CsDevModelPageVO csDevModelPageVO = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
|
||||
if (Objects.isNull(csDevModelPageVO)){
|
||||
log.info(AccessResponseEnum.MODEL_NO_FIND.getMessage());
|
||||
} else {
|
||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setDid("0");
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(TypeEnum.TYPE_5.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
||||
//将装置状态改为接入
|
||||
equipmentFeignClient.updateStatusBynDid(nDid, AccessEnum.ACCESS.getCode());
|
||||
//设置心跳时间,超时改为掉线
|
||||
redisUtil.saveByKeyWithExpire("MQTT:" + nDid,Instant.now().toEpochMilli(),180L);
|
||||
}
|
||||
});
|
||||
}
|
||||
//网关处理 生成报文下发给装置,装置响应版本
|
||||
else if (Objects.equals(dictCode, DicDataEnum.GATEWAY_DEV.getCode())){
|
||||
//todo 处理待定
|
||||
System.out.println("网关设备判断");
|
||||
}
|
||||
} else {
|
||||
log.info(AccessResponseEnum.NDID_NO_FIND.getMessage());
|
||||
List<DevModInfoDto> list = modelDto.getMsg().getDevMod();
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
log.error(AccessResponseEnum.MODEL_VERSION_ERROR.getMessage());
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_VERSION_ERROR);
|
||||
}
|
||||
//校验前置传递的装置模板库中是否存在
|
||||
list.forEach(item->{
|
||||
CsDevModelPO po = devModelFeignClient.findModel(item.getDevType(),item.getVersionNo(),item.getVersionDate()).getData();
|
||||
if (Objects.isNull(po)){
|
||||
log.error(AccessResponseEnum.MODEL_NO_FIND.getMessage());
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_NO_FIND);
|
||||
}
|
||||
});
|
||||
//fixme 这边先写死模板id,后期要选择电能质量的模板来确定监测点个数
|
||||
String modelId = "1";
|
||||
List<CsLineModel> lineList = csLineModelService.getMonitorNumByModelId(modelId);
|
||||
String key = "LINE" + nDid;
|
||||
//存储监测点模板信息,用于界面回显
|
||||
redisUtil.saveByKey(key,lineList);
|
||||
//存储模板id
|
||||
//todo 这边也是要调整的
|
||||
String key2 = "MODEL" + nDid;
|
||||
redisUtil.saveByKey(key2,modelId);
|
||||
redisUtil.delete(nDid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +182,7 @@ public class MqttMessageHandler {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void devHeartBeat(String topic, MqttMessage message, @NamedValue("version") String version, @NamedValue("edgeId") String nDid, @Payload String payload) {
|
||||
//响应请求
|
||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
HeartBeatDto heartBeatDto = new HeartBeatDto();
|
||||
heartBeatDto.setTime(System.currentTimeMillis()/1000);
|
||||
reqAndResParam.setMid(1);
|
||||
@@ -221,7 +193,7 @@ public class MqttMessageHandler {
|
||||
reqAndResParam.setMsg(heartBeatDto);
|
||||
publisher.send("/Dev/PfmRsp/"+version+"/"+nDid,PubUtils.obj2json(reqAndResParam),1,false);
|
||||
//处理业务逻辑
|
||||
ReqAndResParam.Res res = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
||||
ReqAndResDto.Res res = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class);
|
||||
Object object = res.getMsg();
|
||||
if (!Objects.isNull(object)){
|
||||
List<String> abnormalList = new ArrayList<>();
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsAlmPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备告警数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsAlmMapper extends MppBaseMapper<CsAlmPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsBmdPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface CsBmdMapper extends MppBaseMapper<CsBmdPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsCtrlPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 控制表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsCtrlMapper extends MppBaseMapper<CsCtrlPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface CsDataArrayMapper extends BaseMapper<CsDataArrayPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface CsDataSetMapper extends BaseMapper<CsDataSetPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsDiPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开入表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsDiMapper extends MppBaseMapper<CsDiPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsDoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开出表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsDoMapper extends MppBaseMapper<CsDoPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface CsEpdPqdMapper extends MppBaseMapper<CsEpdPqdPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsEvtMapper extends MppBaseMapper<CsEvtPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtParmPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参数表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsEvtParmMapper extends MppBaseMapper<CsEvtParmPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点模板表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
public interface CsLineModelMapper extends BaseMapper<CsLineModel> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsNetDevMapper extends BaseMapper<CsNetDevPO> {
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsParmPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsParmMapper extends MppBaseMapper<CsParmPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsPrjInfoMapper extends BaseMapper<CsPrjInfoPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsSetPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备定值数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsSetMapper extends MppBaseMapper<CsSetPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsSoftInfoMapper extends BaseMapper<CsSoftInfoPO> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.access.pojo.po.CsStsPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 状态表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface CsStsMapper extends MppBaseMapper<CsStsPO> {
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsTopicPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-12
|
||||
*/
|
||||
@Mapper
|
||||
public interface CsTopicMapper extends BaseMapper<CsTopicPO> {
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.access.mapper.CsEpdPqdMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IAccessService {
|
||||
|
||||
/**
|
||||
* 设备注册(1.判断此装置是否完成出厂设置 2.判断此装置是否能正常通讯)
|
||||
* 1.根据nDid获取装置的信息(设备型号、网关识别码)
|
||||
* 2.发送MQTT信息给装置
|
||||
* 3.装置响应则修改装置状态;3分钟未响应则生成告警信息
|
||||
* @param nDid 网关识别码
|
||||
*/
|
||||
void add(String nDid);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsAlmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备告警数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsAlmService {
|
||||
|
||||
void saveData(List<CsAlmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.access.pojo.po.CsBmdPO;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface ICsBmdService {
|
||||
|
||||
void saveData(List<CsBmdPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsCtrlPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 控制表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsCtrlService {
|
||||
|
||||
void saveData(List<CsCtrlPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface ICsDataArrayService {
|
||||
|
||||
void saveData(List<CsDataArrayPO> list);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface ICsDataSetService {
|
||||
|
||||
CsDataSetPO addOne(CsDataSetPO csDataSetPo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/3 15:39
|
||||
*/
|
||||
|
||||
public interface ICsDevModelService {
|
||||
|
||||
/**
|
||||
* 解析模板文件->入库
|
||||
* @param devModelParam
|
||||
*/
|
||||
void addModel(DevModelParam devModelParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/4 13:43
|
||||
*/
|
||||
|
||||
public interface ICsDeviceService {
|
||||
|
||||
/**
|
||||
* 直连设备注册
|
||||
* @param nDid 设备识别码
|
||||
*/
|
||||
void devRegister(String nDid);
|
||||
|
||||
/**
|
||||
* MQTT连接成功,获取装置所用的模板信息
|
||||
* @param nDid
|
||||
*/
|
||||
Object getModel(String nDid);
|
||||
|
||||
/**
|
||||
* MQTT连接成功,获取装置所用的模板信息
|
||||
* @param devAccessParam
|
||||
*/
|
||||
void devAccess(DevAccessParam devAccessParam);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDiPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开入表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsDiService {
|
||||
|
||||
void saveData(List<CsDiPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDoPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开出表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsDoService {
|
||||
|
||||
void saveData(List<CsDoPO> list);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface ICsEpdPqdService {
|
||||
|
||||
void saveData(List<CsEpdPqdPO> list);
|
||||
|
||||
// CsEpdPqdPO findOne(Integer idx);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEvtParmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参数表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsEvtParmService {
|
||||
|
||||
boolean saveData(List<CsEvtParmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEvtPO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsEvtService {
|
||||
|
||||
Map<String,String> saveData(List<CsEvtPO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点模板表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
public interface ICsLineModelService extends IService<CsLineModel> {
|
||||
|
||||
/**
|
||||
* 获取模板下监测点个数
|
||||
* @param id 模板Id
|
||||
*/
|
||||
List<CsLineModel> getMonitorNumByModelId(String id);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsNetDevService {
|
||||
|
||||
boolean saveData(CsNetDevPO csNetDevPo);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsParmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsParmService {
|
||||
|
||||
void saveData(List<CsParmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsPrjInfoService {
|
||||
|
||||
CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPO);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsSetPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备定值数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsSetService {
|
||||
|
||||
void saveData(List<CsSetPO> list);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsSoftInfoService {
|
||||
|
||||
CsSoftInfoPO saveData(CsSoftInfoPO csSoftInfoPo);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsStsPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 状态表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsStsService {
|
||||
|
||||
void saveData(List<CsStsPO> list);
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.access.pojo.po.CsTopicPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-12
|
||||
*/
|
||||
public interface ICsTopicService {
|
||||
|
||||
void askDevTopic(String nDid);
|
||||
|
||||
boolean addList(List<CsTopicPO> list);
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDataArrayService {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDataSetService {
|
||||
|
||||
void add();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDevModelService {
|
||||
|
||||
/**
|
||||
* 直连装置录入模板信息
|
||||
* 1.解析模板文件,将数据录入库中
|
||||
* 2.将文件上传至文件服务器保存起来,先以装置型号-版本号-时间作为名称名称
|
||||
* @param devModelParam 模板文件参数
|
||||
*/
|
||||
void add(DevModelParam devModelParam);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.pojo.dto.devModel.TemplateDto;
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.service.ICsDevModelService;
|
||||
import com.njcn.access.utils.JsonUtil;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/3 15:40
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Override
|
||||
public void addModel(DevModelParam devModelParam) {
|
||||
String json = null;
|
||||
try {
|
||||
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
|
||||
Gson gson = new Gson();
|
||||
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
||||
//模板文件存入文件服务器
|
||||
//String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
|
||||
String filePath = "";
|
||||
System.out.println("templateDto==:" + templateDto);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.service.ICsDeviceService;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelRelationAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/4 13:43
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CsDeviceServiceImpl.class);
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final CsLineTopologyFeignClient csLineTopologyFeignClient;
|
||||
|
||||
private final DevModelRelationFeignClient devModelRelationFeignClient;
|
||||
|
||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void devRegister(String nDid) {
|
||||
//1.判断nDid是否存在
|
||||
CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
if (Objects.isNull(csEquipmentDeliveryVO.getNdid())){
|
||||
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||
}
|
||||
//2.判断设备是否是直连设备
|
||||
SysDicTreePO sysDicTreePo = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData();
|
||||
if (Objects.isNull(sysDicTreePo)){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_NOT_FIND);
|
||||
}
|
||||
String code = sysDicTreePo.getCode();
|
||||
if (!Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode())){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_IS_NOT_ZL);
|
||||
}
|
||||
//3.MQTT询问装置用的模板,并判断库中是否存在模板
|
||||
//存在则建立关系;不存在则告警出来
|
||||
SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData();
|
||||
if (Objects.isNull(dictData)){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_MODEL_NOT_FIND);
|
||||
}
|
||||
String devModel = dictData.getCode();
|
||||
zhiLianRegister(nDid,devModel);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
//这边使用redis缓存来判断装置是否连接MQTT或者是否出现异常
|
||||
if (Objects.isNull(redisUtil.getObjectByKey(nDid))){
|
||||
logger.error("装置注册失败,请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.REGISTER_ERROR);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModel(String nDid) {
|
||||
Object model = null;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
String key = "LINE" + nDid;
|
||||
model = redisUtil.getObjectByKey(key);
|
||||
if (Objects.isNull(model)){
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_MISS);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void devAccess(DevAccessParam devAccessParam) {
|
||||
try {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(devAccessParam.getNDid()).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
List<AppLineTopologyDiagramPO> appLineTopologyDiagramPoList = new ArrayList<>();
|
||||
//1.录入装置台账信息
|
||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||
csLedgerParam.setId(vo.getId());
|
||||
csLedgerParam.setPid(devAccessParam.getProjectId());
|
||||
csLedgerParam.setName(vo.getName());
|
||||
csLedgerParam.setLevel(2);
|
||||
csLedgerParam.setSort(0);
|
||||
csLedgerFeignClient.add(csLedgerParam);
|
||||
//2.监测点表录入关系
|
||||
devAccessParam.getList().forEach(item->{
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
CsLinePO po = new CsLinePO();
|
||||
po.setLineId(id);
|
||||
po.setName(item.getName());
|
||||
po.setPosition(item.getPosition());
|
||||
po.setVolGrade(item.getVolGrade());
|
||||
//todo 目前ct、pt数据不确定 后期补
|
||||
//po.setPtRatio(item.getPtRatio());
|
||||
//po.setCtRatio(item.getCtRatio());
|
||||
po.setStatus(1);
|
||||
csLinePoList.add(po);
|
||||
CsLedgerParam param = new CsLedgerParam();
|
||||
param.setId(id);
|
||||
param.setPid(vo.getId());
|
||||
param.setName(item.getName());
|
||||
param.setLevel(3);
|
||||
param.setSort(0);
|
||||
csLedgerFeignClient.add(param).getData();
|
||||
AppLineTopologyDiagramPO appLineTopologyDiagramPo = new AppLineTopologyDiagramPO();
|
||||
appLineTopologyDiagramPo.setId(devAccessParam.getTopologyDiagram());
|
||||
appLineTopologyDiagramPo.setLineId(id);
|
||||
appLineTopologyDiagramPo.setLat(item.getLat());
|
||||
appLineTopologyDiagramPo.setLng(item.getLng());
|
||||
appLineTopologyDiagramPo.setStatus("1");
|
||||
appLineTopologyDiagramPoList.add(appLineTopologyDiagramPo);
|
||||
});
|
||||
csLineFeignClient.addLineList(csLinePoList);
|
||||
//3.监测点拓扑图表录入关系
|
||||
csLineTopologyFeignClient.addList(appLineTopologyDiagramPoList);
|
||||
//4.新增装置-模板关系
|
||||
String modelId = redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()).toString();
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||
csDevModelRelationAddParm.setModelId(modelId);
|
||||
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
||||
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
||||
//5.修改装置状态
|
||||
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.ACCESS.getCode());
|
||||
//6.设置心跳时间,超时改为掉线
|
||||
redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
||||
//7.绑定装置和人的关系
|
||||
CsDeviceUserPO po = new CsDeviceUserPO();
|
||||
po.setPrimaryUserId(RequestUtil.getUserIndex());
|
||||
po.setSubUserId(RequestUtil.getUserIndex());
|
||||
po.setDeviceId(vo.getId());
|
||||
csDeviceUserFeignClient.add(Collections.singletonList(po));
|
||||
//8.删除redis监测点模板信息
|
||||
redisUtil.delete("LINE" + devAccessParam.getNDid());
|
||||
//todo 9.记录操作日志
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void zhiLianRegister(String nDid,String devType) {
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setDid("0");
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(TypeEnum.TYPE_2.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
AccessDto accessDto = new AccessDto();
|
||||
accessDto.setNDid(nDid);
|
||||
accessDto.setDevType(devType);
|
||||
reqAndResParam.setMsg(accessDto);
|
||||
publisher.send("/Pfm/Reg/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsLineModelMapper;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
import com.njcn.access.service.ICsLineModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点模板表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
@Service
|
||||
public class CsLineModelServiceImpl extends ServiceImpl<CsLineModelMapper, CsLineModel> implements ICsLineModelService {
|
||||
|
||||
@Override
|
||||
public List<CsLineModel> getMonitorNumByModelId(String id) {
|
||||
return this.lambdaQuery().eq(CsLineModel::getPid,id).list();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.alibaba.csp.sentinel.util.TimeUtil;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.handler.MqttMessageHandler;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||
import com.njcn.access.service.IAccessService;
|
||||
import com.njcn.algorithm.api.CsEdDataFeignClient;
|
||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/3/31 9:21
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AccessServiceImpl implements IAccessService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class);
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final CsEdDataFeignClient csEdDataFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void add(String nDid) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
if (Objects.isNull(vo.getNdid())){
|
||||
logger.error("平台侧无此网关信息,请先录入!");
|
||||
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||
} else {
|
||||
HttpResult<CsEdDataVO> result = csEdDataFeignClient.findByDevTypeId(vo.getDevModel());
|
||||
String typeId = result.getData().getType();
|
||||
if(Objects.isNull(typeId)) {
|
||||
logger.error("平台侧无此装置类型,请先录入!");
|
||||
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
|
||||
} else {
|
||||
String type = dicDataFeignClient.getDicDataById(typeId).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.GATEWAY_DEV.getCode(),type)) {
|
||||
//处理网关设备
|
||||
System.out.println("网关");
|
||||
} else if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),type)) {
|
||||
//处理直连设备
|
||||
zhiLianRegister(nDid,vo.getDevModel());
|
||||
} else {
|
||||
logger.error("请求注册的装置类型错误(不是网关或者直连设备),请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.DEV_TYPE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
//这边使用redis缓存来判断装置是否连接MQTT
|
||||
if(Objects.isNull(redisUtil.getObjectByKey(nDid))) {
|
||||
logger.error("未收到装置注册响应,请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.NO_RECEIVE_FROM_DEV);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void zhiLianRegister(String nDid,String devType) {
|
||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setDid("0");
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(TypeEnum.TYPE_2.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
AccessDto accessDto = new AccessDto();
|
||||
accessDto.setNDid(nDid);
|
||||
accessDto.setDevType(devType);
|
||||
reqAndResParam.setMsg(accessDto);
|
||||
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsAlmMapper;
|
||||
import com.njcn.access.pojo.po.CsAlmPO;
|
||||
import com.njcn.access.service.ICsAlmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备告警数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsAlmServiceImpl extends MppServiceImpl<CsAlmMapper, CsAlmPO> implements ICsAlmService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsAlmPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsBmdMapper;
|
||||
import com.njcn.access.pojo.po.CsBmdPO;
|
||||
import com.njcn.access.service.ICsBmdService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
@Service
|
||||
public class CsBmdServiceImpl extends MppServiceImpl<CsBmdMapper, CsBmdPO> implements ICsBmdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsBmdPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsCtrlMapper;
|
||||
import com.njcn.access.pojo.po.CsCtrlPO;
|
||||
import com.njcn.access.service.ICsCtrlService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 控制表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsCtrlServiceImpl extends MppServiceImpl<CsCtrlMapper, CsCtrlPO> implements ICsCtrlService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsCtrlPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsDataArrayMapper;
|
||||
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||
import com.njcn.access.service.ICsDataArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@Service
|
||||
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArrayPO> implements ICsDataArrayService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDataArrayPO> list) {
|
||||
this.saveBatch(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsDataSetMapper;
|
||||
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||
import com.njcn.access.service.ICsDataSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@Service
|
||||
public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSetPO> implements ICsDataSetService {
|
||||
|
||||
@Override
|
||||
public CsDataSetPO addOne(CsDataSetPO csDataSetPo) {
|
||||
this.save(csDataSetPo);
|
||||
return csDataSetPo;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsDiMapper;
|
||||
import com.njcn.access.pojo.po.CsDiPO;
|
||||
import com.njcn.access.service.ICsDiService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开入表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsDiServiceImpl extends MppServiceImpl<CsDiMapper, CsDiPO> implements ICsDiService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDiPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsDoMapper;
|
||||
import com.njcn.access.pojo.po.CsDoPO;
|
||||
import com.njcn.access.service.ICsDoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开出表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsDoServiceImpl extends MppServiceImpl<CsDoMapper, CsDoPO> implements ICsDoService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDoPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.mapper.CsEpdPqdMapper;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
import com.njcn.access.service.ICsEpdPqdService;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
@Service
|
||||
public class CsEpdPqdServiceImpl extends MppServiceImpl<CsEpdPqdMapper, CsEpdPqdPO> implements ICsEpdPqdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsEpdPqdPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public CsEpdPqdPO findOne(Integer idx) {
|
||||
// LambdaQueryWrapper<CsEpdPqdPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.eq(CsEpdPqdPO::getClassId, DataType.POWER_DATA).eq(CsEpdPqdPO::getIdx,idx);
|
||||
// CsEpdPqdPO csEpdPqdPo = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
// if (Objects.isNull(csEpdPqdPo)) {
|
||||
// throw new BusinessException(AccessResponseEnum.DICT_MISSING);
|
||||
// }
|
||||
// return csEpdPqdPo;
|
||||
// }
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsEvtParmMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtParmPO;
|
||||
import com.njcn.access.service.ICsEvtParmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参数表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsEvtParmServiceImpl extends MppServiceImpl<CsEvtParmMapper, CsEvtParmPO> implements ICsEvtParmService {
|
||||
|
||||
@Override
|
||||
public boolean saveData(List<CsEvtParmPO> list) {
|
||||
return this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsEvtMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtPO;
|
||||
import com.njcn.access.service.ICsEvtService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsEvtServiceImpl extends MppServiceImpl<CsEvtMapper, CsEvtPO> implements ICsEvtService {
|
||||
|
||||
@Override
|
||||
public Map<String,String> saveData(List<CsEvtPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
List<String> nameList = list.stream().map(CsEvtPO::getName).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsEvtPO> lambdaQueryWrapper = new LambdaQueryWrapper<CsEvtPO>();
|
||||
lambdaQueryWrapper.in(CsEvtPO::getName,nameList);
|
||||
List<CsEvtPO> list1 = this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
list1.forEach(item->{
|
||||
map.put(item.getName(),item.getId());
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.mapper.CsNetDevMapper;
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
import com.njcn.access.service.ICsNetDevService;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsNetDevServiceImpl extends ServiceImpl<CsNetDevMapper, CsNetDevPO> implements ICsNetDevService {
|
||||
|
||||
@Override
|
||||
public boolean saveData(CsNetDevPO csNetDevPo) {
|
||||
LambdaQueryWrapper<CsNetDevPO> lambdaQueryWrapper = new LambdaQueryWrapper<CsNetDevPO>();
|
||||
lambdaQueryWrapper.eq(CsNetDevPO::getDevType,csNetDevPo.getDevType())
|
||||
.eq(CsNetDevPO::getTime,csNetDevPo.getTime())
|
||||
.eq(CsNetDevPO::getVersion,csNetDevPo.getVersion())
|
||||
.eq(CsNetDevPO::getStatus,1);
|
||||
CsNetDevPO po = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
if (!Objects.isNull(po)){
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||
}
|
||||
return this.save(csNetDevPo);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsParmMapper;
|
||||
import com.njcn.access.pojo.po.CsParmPO;
|
||||
import com.njcn.access.service.ICsParmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsParmServiceImpl extends MppServiceImpl<CsParmMapper, CsParmPO> implements ICsParmService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsParmPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsPrjInfoMapper;
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
import com.njcn.access.service.ICsPrjInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsPrjInfoServiceImpl extends ServiceImpl<CsPrjInfoMapper, CsPrjInfoPO> implements ICsPrjInfoService {
|
||||
|
||||
@Override
|
||||
public CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPo) {
|
||||
this.save(csPrjInfoPo);
|
||||
return csPrjInfoPo;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsSetMapper;
|
||||
import com.njcn.access.pojo.po.CsSetPO;
|
||||
import com.njcn.access.service.ICsSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备定值数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsSetServiceImpl extends MppServiceImpl<CsSetMapper, CsSetPO> implements ICsSetService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsSetPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsSoftInfoMapper;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
import com.njcn.access.service.ICsSoftInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsSoftInfoServiceImpl extends ServiceImpl<CsSoftInfoMapper, CsSoftInfoPO> implements ICsSoftInfoService {
|
||||
|
||||
@Override
|
||||
public CsSoftInfoPO saveData(CsSoftInfoPO entity) {
|
||||
this.save(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsStsMapper;
|
||||
import com.njcn.access.pojo.po.CsStsPO;
|
||||
import com.njcn.access.service.ICsStsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 状态表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsStsServiceImpl extends MppServiceImpl<CsStsMapper, CsStsPO> implements ICsStsService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsStsPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.mapper.CsTopicMapper;
|
||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||
import com.njcn.access.pojo.po.CsTopicPO;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-12
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsTopicServiceImpl extends ServiceImpl<CsTopicMapper, CsTopicPO> implements ICsTopicService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CsTopicServiceImpl.class);
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
@Override
|
||||
public void askDevTopic(String nDid) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
if (Objects.isNull(vo)){
|
||||
logger.error("平台侧无此网关信息,请先录入!");
|
||||
return;
|
||||
}
|
||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setDid("0");
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(TypeEnum.TYPE_1.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
reqAndResParam.setMsg(null);
|
||||
publisher.send("/Pfm/Topic/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addList(List<CsTopicPO> list) {
|
||||
return this.saveOrUpdateBatch(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.njcn.access.service.IDataArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/18 11:06
|
||||
*/
|
||||
@Service
|
||||
public class DataArrayServiceImpl implements IDataArrayService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.njcn.access.service.IDataSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/18 11:06
|
||||
*/
|
||||
@Service
|
||||
public class DataSetServiceImpl implements IDataSetService {
|
||||
@Override
|
||||
public void add() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,638 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.data.*;
|
||||
import com.njcn.access.pojo.dto.devModel.*;
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.pojo.po.*;
|
||||
import com.njcn.access.service.*;
|
||||
import com.njcn.access.utils.JsonUtil;
|
||||
import com.njcn.algorithm.api.CsDictFeignClient;
|
||||
import com.njcn.algorithm.api.DevModelFeignClient;
|
||||
import com.njcn.algorithm.pojo.dto.CsDictDTO;
|
||||
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.algorithm.pojo.po.CsDevModelPO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLOutput;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 10:37
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DevModelServiceImpl implements IDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final CsDictFeignClient csDictFeignClient;
|
||||
|
||||
private final ICsNetDevService csNetDevService;
|
||||
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
|
||||
private final ICsPrjInfoService csPrjInfoService;
|
||||
|
||||
private final ICsEpdPqdService csEpdPqdService;
|
||||
|
||||
private final ICsBmdService csBmdService;
|
||||
|
||||
private final ICsEvtService csEvtService;
|
||||
|
||||
private final ICsEvtParmService csEvtParmService;
|
||||
|
||||
private final ICsAlmService csAlmService;
|
||||
|
||||
private final ICsStsService csStsService;
|
||||
|
||||
private final ICsDiService csDiService;
|
||||
|
||||
private final ICsDoService csDoService;
|
||||
|
||||
private final ICsParmService csParmService;
|
||||
|
||||
private final ICsCtrlService csCtrlService;
|
||||
|
||||
private final ICsSetService csSetService;
|
||||
|
||||
private final ICsDataSetService csDataSetService;
|
||||
|
||||
private final ICsDataArrayService csDataArrayService;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(DevModelParam devModelParam) {
|
||||
String json = null;
|
||||
try {
|
||||
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
|
||||
Gson gson = new Gson();
|
||||
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
||||
//新增网关信息描述表
|
||||
// insertNetDevMod(templateDto.getNetDevModDto());
|
||||
//模板文件存入文件服务器
|
||||
//String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
|
||||
String filePath = "";
|
||||
//新增设备数据模板
|
||||
insertDevMod(templateDto.getDevModDto(),filePath);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("文件转成json出现异常");
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增直连设备、网关模板信息
|
||||
*/
|
||||
public void insertNetDevMod(NetDevModDto netDevModDto) {
|
||||
SoftInfoDto softInfoDto = netDevModDto.getDataList().get(0).getSoftInfoDto();
|
||||
PrjInfoDto prjInfoDto = netDevModDto.getDataList().get(0).getPrjInfoDto();
|
||||
CsNetDevPO csNetDevPo = new CsNetDevPO();
|
||||
BeanUtils.copyProperties(netDevModDto,csNetDevPo);
|
||||
csNetDevPo.setTime(LocalDate.parse(netDevModDto.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
csNetDevPo.setStatus(1);
|
||||
if (!Objects.isNull(softInfoDto)){
|
||||
CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
BeanUtils.copyProperties(softInfoDto,csSoftInfoPo);
|
||||
csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId();
|
||||
csNetDevPo.setSoftInfoId(softInfoId);
|
||||
}
|
||||
if (!Objects.isNull(prjInfoDto)){
|
||||
CsPrjInfoPO csPrjInfoPo = new CsPrjInfoPO();
|
||||
BeanUtils.copyProperties(prjInfoDto,csPrjInfoPo);
|
||||
String prjInfoId = csPrjInfoService.saveData(csPrjInfoPo).getId();
|
||||
csNetDevPo.setPrjInfoId(prjInfoId);
|
||||
}
|
||||
csNetDevService.saveData(csNetDevPo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据模板(装置类型分类)
|
||||
*/
|
||||
public void insertDevMod(DevModDto devModDto,String filePath) {
|
||||
// String devType = devModDto.getDevType();
|
||||
// String version = devModDto.getVersion();
|
||||
// String time = devModDto.getTime();
|
||||
// CsDevModelPO csDevModelPo = devModelFeignClient.findModel(devType,version,time).getData();
|
||||
// if (!Objects.isNull(csDevModelPo)){
|
||||
// throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||
// }
|
||||
// /**录入基础模板数据*/
|
||||
// CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
||||
// csDevModelAddParm.setDevType(devType);
|
||||
// csDevModelAddParm.setName(devType);
|
||||
// csDevModelAddParm.setVersionNo(version);
|
||||
// csDevModelAddParm.setVersionDate(LocalDateTime.parse(time, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// csDevModelAddParm.setFilePath(filePath);
|
||||
// SoftInfoDto softInfoDto = devModDto.getDataList().get(0).getSoftInfoDto();
|
||||
// //录入系统软件表
|
||||
// if (!Objects.isNull(softInfoDto)){
|
||||
// CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
// BeanUtils.copyProperties(softInfoDto,csSoftInfoPo);
|
||||
// csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId();
|
||||
// csDevModelAddParm.setSoftInfoId(softInfoId);
|
||||
// }
|
||||
// devModelFeignClient.addDevModel(csDevModelAddParm);
|
||||
// /**录入数据模型列表*/
|
||||
//录入EPD
|
||||
List<EpdPqdDto> epdDto = devModDto.getDataList().get(0).getEpdDto();
|
||||
if (!CollectionUtils.isEmpty(epdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EPD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.EPD_DICT_MISSING);
|
||||
}
|
||||
insertEpdPqd(epdDto,dictData);
|
||||
}
|
||||
//录入PQD
|
||||
List<EpdPqdDto> pqdDto = devModDto.getDataList().get(0).getPqdDto();
|
||||
if (!CollectionUtils.isEmpty(pqdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.PQD_DICT_MISSING);
|
||||
}
|
||||
insertEpdPqd(pqdDto,dictData);
|
||||
}
|
||||
//录入Bmd
|
||||
List<BmdDto> bmdDto = devModDto.getDataList().get(0).getBmdDto();
|
||||
if (!CollectionUtils.isEmpty(bmdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.BMD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.BMD_DICT_MISSING);
|
||||
}
|
||||
insertBmd(bmdDto,dictData);
|
||||
}
|
||||
//录入Evt
|
||||
List<EvtDto> evtDto = devModDto.getDataList().get(0).getEvtDto();
|
||||
if (!CollectionUtils.isEmpty(evtDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EVT.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.Evt_DICT_MISSING);
|
||||
}
|
||||
insertEvt(evtDto,dictData);
|
||||
}
|
||||
//录入Alm
|
||||
List<AlmDto> almDto = devModDto.getDataList().get(0).getAlmDto();
|
||||
if (!CollectionUtils.isEmpty(almDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.ALM.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.ALM_DICT_MISSING);
|
||||
}
|
||||
insertAlm(almDto,dictData);
|
||||
}
|
||||
//录入Sts
|
||||
List<StsDto> stsDto = devModDto.getDataList().get(0).getStsDto();
|
||||
if (!CollectionUtils.isEmpty(stsDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.STS.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.STS_DICT_MISSING);
|
||||
}
|
||||
insertSts(stsDto,dictData);
|
||||
}
|
||||
//录入Di
|
||||
List<DiDto> diDto = devModDto.getDataList().get(0).getDiDto();
|
||||
if (!CollectionUtils.isEmpty(diDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DI.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.DI_DICT_MISSING);
|
||||
}
|
||||
insertDi(diDto,dictData);
|
||||
}
|
||||
//录入Do
|
||||
List<DoDto> doDto = devModDto.getDataList().get(0).getDoDto();
|
||||
if (!CollectionUtils.isEmpty(doDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DO.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.DO_DICT_MISSING);
|
||||
}
|
||||
insertDo(doDto,dictData);
|
||||
}
|
||||
//录入Parm
|
||||
List<ParmDto> parmDto = devModDto.getDataList().get(0).getParmDto();
|
||||
if (!CollectionUtils.isEmpty(parmDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PARM.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.PARM_DICT_MISSING);
|
||||
}
|
||||
insertParm(parmDto,dictData);
|
||||
}
|
||||
//录入Set
|
||||
List<SetDto> setDto = devModDto.getDataList().get(0).getSetDto();
|
||||
if (!CollectionUtils.isEmpty(setDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SET.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.SET_DICT_MISSING);
|
||||
}
|
||||
insertSet(setDto,dictData);
|
||||
}
|
||||
//录入InSet
|
||||
List<InSetDto> inSetDto = devModDto.getDataList().get(0).getInSetDto();
|
||||
if (!CollectionUtils.isEmpty(inSetDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.INSET.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.INSET_DICT_MISSING);
|
||||
}
|
||||
insertInSet(inSetDto,dictData);
|
||||
}
|
||||
//录入Ctrl
|
||||
List<CtrlDto> ctrlDto = devModDto.getDataList().get(0).getCtrlDto();
|
||||
if (!CollectionUtils.isEmpty(ctrlDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.CTRL.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.CTRL_DICT_MISSING);
|
||||
}
|
||||
insertCtrl(ctrlDto,dictData);
|
||||
}
|
||||
|
||||
|
||||
// /**录入数据集*/
|
||||
// List<DataSetDto> dataSetDtoList = devModDto.getDataSetDtoList();
|
||||
// if (!CollectionUtils.isEmpty(dataSetDtoList)){
|
||||
// insertDataSet(dataSetDtoList,"60b55915717c0cfd8935e04633657034");
|
||||
// }
|
||||
// /**录入逻辑子设备序列*/
|
||||
// List<ClDevDto> clDevDtoList = devModDto.getClDevDtoList();
|
||||
}
|
||||
|
||||
/**
|
||||
* EPD、PQD字典录入
|
||||
*/
|
||||
public void insertEpdPqd(List<EpdPqdDto> epdPqdDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = epdPqdDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (Objects.isNull(item.getPhase())){
|
||||
param.setPhase("M");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(item.getStatMethod())){
|
||||
param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bmd字典录入
|
||||
*/
|
||||
public void insertBmd(List<BmdDto> bmdDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = bmdDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (Objects.isNull(item.getPhase())){
|
||||
param.setPhase("M");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(item.getStatMethod())){
|
||||
param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evt字典录入
|
||||
*/
|
||||
public void insertEvt(List<EvtDto> evtDto,DictData dictData) {
|
||||
Map<String,List<EvtParamDto>> map = new HashMap<>();
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = evtDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
map.put(item.getName(),item.getParam());
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
List<CsEvtParmPO> evtParmList = new ArrayList<>();
|
||||
Map<String,String> map2 = epdFeignClient.addEvt(paramList).getData();
|
||||
paramList.forEach(item->{
|
||||
List<EvtParamDto> list = map.get(item.getName());
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(item2->{
|
||||
CsEvtParmPO csEvtParmPo = new CsEvtParmPO();
|
||||
BeanUtils.copyProperties(item2,csEvtParmPo);
|
||||
csEvtParmPo.setPid(map2.get(item.getName()));
|
||||
evtParmList.add(csEvtParmPo);
|
||||
});
|
||||
}
|
||||
});
|
||||
csEvtParmService.saveData(evtParmList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alm字典录入
|
||||
*/
|
||||
public void insertAlm(List<AlmDto> almDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = almDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sts字典录入
|
||||
*/
|
||||
public void insertSts(List<StsDto> stsDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = stsDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Di字典录入
|
||||
*/
|
||||
public void insertDi(List<DiDto> diDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = diDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do字典录入
|
||||
*/
|
||||
public void insertDo(List<DoDto> doDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = doDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parm字典录入
|
||||
*/
|
||||
public void insertParm(List<ParmDto> parmDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = parmDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (!CollectionUtils.isEmpty(item.getSetValue())){
|
||||
param.setSetValue(item.getSetValue().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set字典录入
|
||||
*/
|
||||
public void insertSet(List<SetDto> setDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = setDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* InSet字典录入
|
||||
*/
|
||||
public void insertInSet(List<InSetDto> inSetDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = inSetDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctrl字典录入
|
||||
*/
|
||||
public void insertCtrl(List<CtrlDto> ctrlDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = ctrlDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (!CollectionUtils.isEmpty(item.getCtlValue())){
|
||||
param.setSetValue(item.getCtlValue().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DataSet录入
|
||||
*/
|
||||
public void insertDataSet(List<DataSetDto> dataSetDtoList,String pid) {
|
||||
dataSetDtoList.forEach(item->{
|
||||
CsDataSetPO csDataSetPo = new CsDataSetPO();
|
||||
BeanUtils.copyProperties(item,csDataSetPo);
|
||||
CsDictDTO csDictDTO = csDictFeignClient.getOwnAndFatherData(item.getName()).getData();
|
||||
csDataSetPo.setAnotherName(csDictDTO.getName());
|
||||
if (csDictDTO.getName().contains("Rt")){
|
||||
csDataSetPo.setDataType("实时数据");
|
||||
} else if (csDictDTO.getName().contains("Stat")){
|
||||
csDataSetPo.setDataType("统计数据");
|
||||
}
|
||||
csDataSetPo.setPid(pid);
|
||||
csDataSetService.addOne(csDataSetPo);
|
||||
List<DataArrayDto> dataArrayDto = item.getDataArrayDtoList();
|
||||
if (!CollectionUtils.isEmpty(dataArrayDto)){
|
||||
insertDataArray(dataArrayDto,csDataSetPo.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* DataArray录入
|
||||
*/
|
||||
public void insertDataArray(List<DataArrayDto> dataArrayDto,String pid) {
|
||||
List<CsDataArrayPO> list = new ArrayList<>();
|
||||
dataArrayDto.forEach(item->{
|
||||
int sort = 0;
|
||||
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||
csDataArrayPo.setPid(pid);
|
||||
list.add(csDataArrayPo);
|
||||
});
|
||||
csDataArrayService.saveData(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ microservice:
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10301
|
||||
#feign接口开启服务熔断降级处理
|
||||
|
||||
Reference in New Issue
Block a user