模板导入功能
This commit is contained in:
@@ -24,7 +24,7 @@ public class AlmDto implements Serializable {
|
||||
@NotNull(message = "告警事件名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "告警事件编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BmdDto implements Serializable {
|
||||
@NotNull(message = "数据名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "数据编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CtrlDto implements Serializable {
|
||||
@NotNull(message = "控制名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "控制编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DoDto implements Serializable {
|
||||
@NotNull(message = "开出信号名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "DO编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class EpdPqdDto implements Serializable {
|
||||
@NotNull(message = "数据名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "数据编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EvtDto implements Serializable {
|
||||
@NotNull(message = "事件信息名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "事件编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ParmDto implements Serializable {
|
||||
@NotNull(message = "参数名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "参数编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SetDto implements Serializable {
|
||||
@NotNull(message = "参数名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "参数编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class StsDto implements Serializable {
|
||||
@NotNull(message = "状态名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "状态编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ApfDto implements Serializable {
|
||||
@NotNull(message = "数据名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("IDX")
|
||||
@SerializedName("Idx")
|
||||
@NotNull(message = "数据编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -43,14 +43,6 @@ public class TemplateDto implements Serializable {
|
||||
@ApiModelProperty(value = "逻辑子设备序列")
|
||||
private List<ClDevDto> clDevDtoList;
|
||||
|
||||
@SerializedName("SoftInfo")
|
||||
@NotEmpty(message = "软件信息,不可为空")
|
||||
private List<SoftInfoDto> softInfoDto;
|
||||
|
||||
@SerializedName("LdevInfo")
|
||||
@NotEmpty(message = "设备信息,不可为空")
|
||||
private List<LDevInfoDto> lDevInfoDto;
|
||||
|
||||
@SerializedName("Apf")
|
||||
@NotEmpty(message = "谐波治理设备Apf,不可为空")
|
||||
private List<ApfDto> apfDto;
|
||||
|
||||
12
iot-access/access-boot/Dockerfile
Normal file
12
iot-access/access-boot/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM eclipse-temurin:8-jdk-centos7
|
||||
MAINTAINER hongawen_13914774158@163.com
|
||||
ENV JAVA_OPTS="-Xms1024m -Xmx1024m"
|
||||
# 挂载时区的目录
|
||||
VOLUME /usr/share/zoneinfo
|
||||
# 设置时区为上海
|
||||
ENV TZ=Asia/Shanghai
|
||||
# 设置时区信息
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
ADD target/accessboot.jar accessboot.jar
|
||||
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /accessboot.jar
|
||||
EXPOSE 10301
|
||||
@@ -87,7 +87,7 @@
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.2.2</version>
|
||||
<executions>
|
||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||
<execution>
|
||||
|
||||
@@ -14,10 +14,8 @@ 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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
@@ -38,10 +36,9 @@ public class CsDevModelController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addModel")
|
||||
@ApiOperation("新增设备模板")
|
||||
@ApiImplicitParam(name = "devModelParam", value = "设备模板参数", required = true)
|
||||
public HttpResult<String> addModel(@RequestBody @Validated DevModelParam devModelParam){
|
||||
public HttpResult<String> addModel(@RequestPart("file") @Validated MultipartFile file){
|
||||
String methodDescribe = getMethodDescribe("addModel");
|
||||
csDevModelService.addModel(devModelParam);
|
||||
csDevModelService.addModel(file);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
@@ -14,8 +14,8 @@ public interface ICsDevModelService {
|
||||
|
||||
/**
|
||||
* 解析模板文件->入库
|
||||
* @param devModelParam
|
||||
* @param file
|
||||
*/
|
||||
void addModel(DevModelParam devModelParam);
|
||||
void addModel(MultipartFile file);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,15 +2,22 @@ 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.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
@@ -25,20 +32,44 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
@Override
|
||||
public void addModel(DevModelParam devModelParam) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addModel(MultipartFile file) {
|
||||
String json = null;
|
||||
try {
|
||||
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
|
||||
json = JsonUtil.convertStreamToString(file.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);
|
||||
//1.录入cs_dev_model表,记录装置型号和模板记录
|
||||
addCsDevModel(templateDto,filePath);
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增cs_dev_model数据
|
||||
*/
|
||||
private CsDevModelPO addCsDevModel(TemplateDto templateDto, String filePath){
|
||||
CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
||||
csDevModelAddParm.setDevTypeName(templateDto.getDevType());
|
||||
csDevModelAddParm.setName(templateDto.getDevType());
|
||||
csDevModelAddParm.setVersionNo(templateDto.getVersion());
|
||||
csDevModelAddParm.setTime(templateDto.getTime());
|
||||
csDevModelAddParm.setFilePath(filePath);
|
||||
CsDevModelPO csDevModel = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
|
||||
return csDevModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
}
|
||||
//3.判断客户端是否在线
|
||||
//mqttUtil.judgeClientOnline(nDid);
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline("access-boot123456");
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline("access-boot1234567");
|
||||
if (!mqttClient){
|
||||
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ spring:
|
||||
refresh: true
|
||||
- data-Id: algorithm-config.yaml
|
||||
refresh: true
|
||||
- data-Id: kafka-config.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
@@ -52,4 +50,4 @@ mybatis-plus:
|
||||
|
||||
|
||||
mqtt:
|
||||
client-id: access-boot123456
|
||||
client-id: access-boot1234567
|
||||
3
pom.xml
3
pom.xml
@@ -36,11 +36,12 @@
|
||||
<!--微服务模块发布地址-->
|
||||
<service.server.url>192.168.1.139</service.server.url>
|
||||
<!--docker仓库地址-->
|
||||
<docker.server.url>192.168.1.31</docker.server.url>
|
||||
<docker.server.url>192.168.1.13</docker.server.url>
|
||||
<!--nacos的ip:port-->
|
||||
<nacos.url>${middle.server.url}:18848</nacos.url>
|
||||
<!--服务器发布内容为空-->
|
||||
<nacos.namespace>415a1c87-33aa-47bd-8e25-13cc456c87ed</nacos.namespace>
|
||||
<!-- <nacos.namespace>3eaa4bd1-bfb6-497b-aba2-47edda305427</nacos.namespace>-->
|
||||
<!--sentinel:port-->
|
||||
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
||||
<!--网关地址,主要用于配置swagger中认证token-->
|
||||
|
||||
Reference in New Issue
Block a user