模板导入功能
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user