Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
472098a2d1
@ -417,8 +417,12 @@ public class DataServiceImpl implements DataService {
|
||||
// 解析interval的数值和单位
|
||||
long intervalInMilliseconds = parseIntervalToMilliseconds(interval);
|
||||
|
||||
//8小时时区
|
||||
long i = 8 * 3600 * 1000L;
|
||||
long timeChina = startTime + i;
|
||||
|
||||
// 计算不能被整除的部分
|
||||
return startTime % intervalInMilliseconds;
|
||||
return timeChina % intervalInMilliseconds;
|
||||
}
|
||||
|
||||
public long parseIntervalToMilliseconds(String interval) {
|
||||
|
@ -13,6 +13,7 @@ import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
import com.das.modules.equipment.entity.SysEquipmentDocs;
|
||||
import com.das.modules.equipment.entity.SysGenExtProps;
|
||||
import com.das.modules.equipment.service.SysEquipmentService;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -196,8 +197,24 @@ public class EquipmentController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
|
||||
public R<SysEquipmentDocs> addFile(Long deviceId, String folderName, MultipartFile file) {
|
||||
SysEquipmentDocs upload = sysEquipmentService.upload(deviceId, folderName, file);
|
||||
public R<List<SysEquipmentDocs>> addFile(Long deviceId, String component,String folderName, List<MultipartFile> fileList) throws Exception {
|
||||
List<SysEquipmentDocs> upload = sysEquipmentService.upload(deviceId, component,folderName, fileList);
|
||||
return R.success(upload);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/file/getList", method = RequestMethod.POST)
|
||||
public R<List<SysEquipmentDocs>> getFileList(Long deviceId, String component) {
|
||||
List<SysEquipmentDocs> fileList = sysEquipmentService.getFileList(deviceId, component);
|
||||
return R.success(fileList);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/file/read", method = RequestMethod.GET)
|
||||
public void readFile(String path, HttpServletResponse response) throws IOException {
|
||||
if (StringUtils.isBlank(path)){
|
||||
throw new ServiceException("请输入浏览的文件路径");
|
||||
}
|
||||
response.setContentType("application/octet-stream");
|
||||
sysEquipmentService.readFileToSteam(path, response.getOutputStream());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.das.modules.equipment.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@ -62,6 +63,7 @@ public class SysEquipmentDto implements Serializable {
|
||||
/**
|
||||
* 安装日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date installDate;
|
||||
|
||||
/**
|
||||
|
@ -18,89 +18,53 @@ public class SysGenExtPropsDto {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String fanName;
|
||||
|
||||
private String fanNumber;
|
||||
|
||||
private String fanType;
|
||||
|
||||
private String fanTypeDetails;
|
||||
|
||||
private String pitchSystemModel;
|
||||
|
||||
private String pitchSystemManufacturer;
|
||||
|
||||
private String pitchSystemDetails;
|
||||
|
||||
private String blade1Model;
|
||||
|
||||
private String blade1Manufacturer;
|
||||
|
||||
private String blade1Details;
|
||||
|
||||
private String blade1BearingModel;
|
||||
|
||||
private String blade1BearingManufacturer;
|
||||
|
||||
private String blade1BearingDetails;
|
||||
|
||||
private String blade2Model;
|
||||
|
||||
private String blade2Manufacturer;
|
||||
|
||||
private String blade2Details;
|
||||
|
||||
private String blade2BearingModel;
|
||||
|
||||
private String blade2BearingManufacturer;
|
||||
|
||||
private String blade2BearingDetails;
|
||||
|
||||
private String blade3Model;
|
||||
|
||||
private String blade3Manufacturer;
|
||||
|
||||
private String blade3Details;
|
||||
|
||||
private String blade3BearingModel;
|
||||
|
||||
private String blade3BearingManufacturer;
|
||||
|
||||
private String blade3BearingDetails;
|
||||
|
||||
private String mainBearingModel;
|
||||
|
||||
private String mainBearingManufacturer;
|
||||
|
||||
private String mainBearingDetails;
|
||||
|
||||
private String gearboxModel;
|
||||
|
||||
private String gearboxManufacturer;
|
||||
|
||||
private String gearboxDetails;
|
||||
|
||||
private String generatorModel;
|
||||
|
||||
private String generatorManufacturer;
|
||||
|
||||
private String generatorDetails;
|
||||
|
||||
private String converterModel;
|
||||
|
||||
private String converterManufacturer;
|
||||
|
||||
private String converterDetails;
|
||||
|
||||
private String mainControlSystemModel;
|
||||
|
||||
private String mainControlSystemManufacturer;
|
||||
|
||||
private String mainControlSystemSoftwareVersion;
|
||||
|
||||
private String mainControlSystemSoftwareVersionDetails;
|
||||
|
||||
private String towerBaseCabinetDetails;
|
||||
|
||||
private String nacelleCabinetDetails;
|
||||
}
|
||||
|
@ -17,12 +17,18 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
public class SysEquipmentDocs {
|
||||
|
||||
@TableId(value = "deviceid")
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "deviceid")
|
||||
private Long deviceId;
|
||||
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
@TableField(value = "component")
|
||||
private String component;
|
||||
|
||||
@TableField(value = "url")
|
||||
private String url;
|
||||
/**
|
||||
|
@ -20,18 +20,6 @@ public class SysGenExtProps {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "fan_name")
|
||||
private String fanName;
|
||||
|
||||
@TableField(value = "fan_Number")
|
||||
private String fanNumber;
|
||||
|
||||
@TableField(value = "fan_type")
|
||||
private String fanType;
|
||||
|
||||
@TableField(value = "fan_type_details")
|
||||
private String fanTypeDetails;
|
||||
|
||||
// Pitch System
|
||||
@TableField(value = "pitch_system_model")
|
||||
private String pitchSystemModel;
|
||||
@ -39,9 +27,6 @@ public class SysGenExtProps {
|
||||
@TableField(value = "pitch_system_manufacturer")
|
||||
private String pitchSystemManufacturer;
|
||||
|
||||
@TableField(value = "pitch_system_details")
|
||||
private String pitchSystemDetails;
|
||||
|
||||
// Blade 1
|
||||
@TableField(value = "blade1_model")
|
||||
private String blade1Model;
|
||||
@ -49,18 +34,12 @@ public class SysGenExtProps {
|
||||
@TableField(value = "blade1_manufacturer")
|
||||
private String blade1Manufacturer;
|
||||
|
||||
@TableField(value = "blade1_details")
|
||||
private String blade1Details;
|
||||
|
||||
@TableField(value = "blade1_bearing_model")
|
||||
private String blade1BearingModel;
|
||||
|
||||
@TableField(value = "blade1_bearing_manufacturer")
|
||||
private String blade1BearingManufacturer;
|
||||
|
||||
@TableField(value = "blade1_bearing_details")
|
||||
private String blade1BearingDetails;
|
||||
|
||||
// Blade 2
|
||||
@TableField(value = "blade2_model")
|
||||
private String blade2Model;
|
||||
@ -68,18 +47,12 @@ public class SysGenExtProps {
|
||||
@TableField(value = "blade2_manufacturer")
|
||||
private String blade2Manufacturer;
|
||||
|
||||
@TableField(value = "blade2_details")
|
||||
private String blade2Details;
|
||||
|
||||
@TableField(value = "blade2_bearing_model")
|
||||
private String blade2BearingModel;
|
||||
|
||||
@TableField(value = "blade2_bearing_manufacturer")
|
||||
private String blade2BearingManufacturer;
|
||||
|
||||
@TableField(value = "blade2_bearing_details")
|
||||
private String blade2BearingDetails;
|
||||
|
||||
// Blade 3
|
||||
@TableField(value = "blade3_model")
|
||||
private String blade3Model;
|
||||
@ -87,18 +60,12 @@ public class SysGenExtProps {
|
||||
@TableField(value = "blade3_manufacturer")
|
||||
private String blade3Manufacturer;
|
||||
|
||||
@TableField(value = "blade3_details")
|
||||
private String blade3Details;
|
||||
|
||||
@TableField(value = "blade3_bearing_model")
|
||||
private String blade3BearingModel;
|
||||
|
||||
@TableField(value = "blade3_bearing_manufacturer")
|
||||
private String blade3BearingManufacturer;
|
||||
|
||||
@TableField(value = "blade3_bearing_details")
|
||||
private String blade3BearingDetails;
|
||||
|
||||
// Main Bearing
|
||||
@TableField(value = "main_bearing_model")
|
||||
private String mainBearingModel;
|
||||
@ -106,9 +73,6 @@ public class SysGenExtProps {
|
||||
@TableField(value = "main_bearing_manufacturer")
|
||||
private String mainBearingManufacturer;
|
||||
|
||||
@TableField(value = "main_bearing_details")
|
||||
private String mainBearingDetails;
|
||||
|
||||
// Gearbox
|
||||
@TableField(value = "gearbox_model")
|
||||
private String gearboxModel;
|
||||
@ -116,9 +80,6 @@ public class SysGenExtProps {
|
||||
@TableField(value = "gearbox_manufacturer")
|
||||
private String gearboxManufacturer;
|
||||
|
||||
@TableField(value = "gearbox_details")
|
||||
private String gearboxDetails;
|
||||
|
||||
// Generator
|
||||
@TableField(value = "generator_model")
|
||||
private String generatorModel;
|
||||
@ -126,9 +87,6 @@ public class SysGenExtProps {
|
||||
@TableField(value = "generator_manufacturer")
|
||||
private String generatorManufacturer;
|
||||
|
||||
@TableField(value = "generator_details")
|
||||
private String generatorDetails;
|
||||
|
||||
// Converter
|
||||
@TableField(value = "converter_model")
|
||||
private String converterModel;
|
||||
@ -136,9 +94,6 @@ public class SysGenExtProps {
|
||||
@TableField(value = "converter_manufacturer")
|
||||
private String converterManufacturer;
|
||||
|
||||
@TableField(value = "converter_details")
|
||||
private String converterDetails;
|
||||
|
||||
// Main Control System
|
||||
@TableField(value = "main_control_system_model")
|
||||
private String mainControlSystemModel;
|
||||
@ -148,15 +103,4 @@ public class SysGenExtProps {
|
||||
|
||||
@TableField(value = "main_control_system_software_version")
|
||||
private String mainControlSystemSoftwareVersion;
|
||||
|
||||
@TableField(value = "main_control_system_software_version_details")
|
||||
private String mainControlSystemSoftwareVersionDetails;
|
||||
|
||||
// Cabinet Details
|
||||
|
||||
@TableField(value = "tower_base_cabinet_details")
|
||||
private String towerBaseCabinetDetails;
|
||||
|
||||
@TableField(value = "nacelle_cabinet_details")
|
||||
private String nacelleCabinetDetails;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,5 +40,9 @@ public interface SysEquipmentService {
|
||||
|
||||
SysGenExtProps querySysEquipmentExtProps(Long id);
|
||||
|
||||
SysEquipmentDocs upload(Long deviceId, String folderName, MultipartFile file);
|
||||
List<SysEquipmentDocs> upload(Long deviceId, String component,String folderName, List<MultipartFile> fileList) throws Exception;
|
||||
|
||||
List<SysEquipmentDocs> getFileList(Long deviceId, String component);
|
||||
|
||||
void readFileToSteam(String path, OutputStream stream);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.das.modules.equipment.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
@ -41,6 +42,7 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
@ -50,10 +52,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.rmi.ServerException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -64,6 +68,7 @@ import java.util.List;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
@Autowired
|
||||
@ -98,6 +103,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
@Autowired
|
||||
private SysEquipmentDocsMapper sysEquipmentDocsMapper;
|
||||
// 7厘米转换为像素(以300 DPI为基准)
|
||||
private static final int TARGET_WIDTH = 826; // 7厘米 * 300 DPI / 2.54
|
||||
private static final int TARGET_HEIGHT = 826; // 7厘米 * 300 DPI / 2.54
|
||||
|
||||
|
||||
@Override
|
||||
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
@ -118,8 +127,8 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
sysEquipment.setRevision(1);
|
||||
sysEquipmentMapper.insert(sysEquipment);
|
||||
//物模型不为空 增加设备物模型mapping缓存
|
||||
if (sysEquipment.getIotModelId() != null){
|
||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||
if (sysEquipment.getIotModelId() != null) {
|
||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(), dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||
}
|
||||
//更新设备缓存
|
||||
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
||||
@ -147,14 +156,14 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysEquipmentMapper.updateById(sysEquipment);
|
||||
|
||||
if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null){
|
||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(),dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||
if (oldModelSysEquipInfo.getIotModelId() == null && sysEquipment.getIotModelId() != null) {
|
||||
dataService.deviceModelMap.put(sysEquipment.getId().toString(), dataService.iotModelMap.get(sysEquipment.getIotModelId().toString()));
|
||||
}
|
||||
//更新设备缓存
|
||||
cacheService.getEquipmentCache().refreshDeviceCache(sysEquipment.getId());
|
||||
if (tdEngineService.checkTableExist("e_"+sysEquipment.getId())){
|
||||
tdEngineService.updateTagDeviceCode("e_"+sysEquipment.getId(),sysEquipment.getCode());
|
||||
tdEngineService.updateTagDeviceName("e_"+sysEquipment.getId(),sysEquipment.getName());
|
||||
if (tdEngineService.checkTableExist("e_" + sysEquipment.getId())) {
|
||||
tdEngineService.updateTagDeviceCode("e_" + sysEquipment.getId(), sysEquipment.getCode());
|
||||
tdEngineService.updateTagDeviceName("e_" + sysEquipment.getId(), sysEquipment.getName());
|
||||
}
|
||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||
BeanCopyUtils.copy(sysEquipment, sysEquipmentVo);
|
||||
@ -187,10 +196,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
public List<SysEquipmentVo> queryAllSysEquipmentList(SysEquipmentDto sysEquipmentDto) {
|
||||
// 查询当前账号机构下的子机构和子设备
|
||||
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
|
||||
if (sysEquipmentDto.getOrgId() !=null){
|
||||
if (sysEquipmentDto.getOrgId() != null) {
|
||||
queryWrapper.eq("org_id", sysEquipmentDto.getOrgId());
|
||||
}
|
||||
if (sysEquipmentDto.getParentEquipmentId() !=null){
|
||||
if (sysEquipmentDto.getParentEquipmentId() != null) {
|
||||
queryWrapper.eq("parent_equipment_id", sysEquipmentDto.getParentEquipmentId());
|
||||
}
|
||||
queryWrapper.eq("object_type", sysEquipmentDto.getObjectType());
|
||||
@ -209,6 +218,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
/**
|
||||
* 设备台账导出Excel
|
||||
*
|
||||
* @param sysEquipmentDto 查询参数
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
@ -278,18 +288,18 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
List<SysEquipment> delSysEquipmentList = new ArrayList<>();
|
||||
// 遍历
|
||||
for (List<Object> row : list) {
|
||||
if (ObjectUtil.isAllNotEmpty(row.get(4),row.get(1),row.get(5))){
|
||||
throw new ServerException("请检查必填参数:"+row);
|
||||
if (ObjectUtil.isAllNotEmpty(row.get(4), row.get(1), row.get(5))) {
|
||||
throw new ServerException("请检查必填参数:" + row);
|
||||
}
|
||||
if (!Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG) && !Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_WIND_FARM)){
|
||||
throw new ServerException("设备类型编码错误"+ row.get(1));
|
||||
if (!Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG) && !Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_WIND_FARM)) {
|
||||
throw new ServerException("设备类型编码错误" + row.get(1));
|
||||
}
|
||||
SysEquipment field = new SysEquipment();
|
||||
// 根据编码获取物模型id
|
||||
if (StringUtils.hasText(row.get(2).toString())) {
|
||||
Long iotModelId = sysIotModelMapper.queryIotModelIdByCode(row.get(2).toString());
|
||||
if (iotModelId == null){
|
||||
throw new ServerException("物模型编码错误,错误编码:"+ row.get(2).toString());
|
||||
if (iotModelId == null) {
|
||||
throw new ServerException("物模型编码错误,错误编码:" + row.get(2).toString());
|
||||
}
|
||||
field.setIotModelId(iotModelId);
|
||||
}
|
||||
@ -323,7 +333,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
field.setParentEquipmentId(Long.valueOf(parentEquipmentId));
|
||||
|
||||
SysEquipmentVo info = sysEquipmentMapper.queryEquipmentInfoByCode(field.getCode());
|
||||
if(info == null) {
|
||||
if (info == null) {
|
||||
if ("I".equals(row.get(0))) {
|
||||
//加入集合
|
||||
// 遍历完一个添加一个
|
||||
@ -348,35 +358,35 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
}
|
||||
}
|
||||
sysEquipmentMapper.insertBatch(addSysEquipmentList);
|
||||
for (SysEquipment item : addSysEquipmentList){
|
||||
if (item.getIotModelId() != null){
|
||||
for (SysEquipment item : addSysEquipmentList) {
|
||||
if (item.getIotModelId() != null) {
|
||||
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
||||
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
||||
dataService.deviceModelMap.put(item.getId().toString(), modelCode);
|
||||
}
|
||||
//更新设备缓存
|
||||
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateSysEquipmentList)) {
|
||||
sysEquipmentMapper.updateBatchById(updateSysEquipmentList);
|
||||
for (SysEquipment item : updateSysEquipmentList){
|
||||
if (item.getIotModelId() != null){
|
||||
for (SysEquipment item : updateSysEquipmentList) {
|
||||
if (item.getIotModelId() != null) {
|
||||
String modelCode = dataService.iotModelMap.get(item.getIotModelId().toString());
|
||||
dataService.deviceModelMap.put(item.getId().toString(),modelCode);
|
||||
dataService.deviceModelMap.put(item.getId().toString(), modelCode);
|
||||
}
|
||||
//更新设备缓存
|
||||
cacheService.getEquipmentCache().refreshDeviceCache(item.getId());
|
||||
|
||||
//更新td表TAG
|
||||
if (tdEngineService.checkTableExist("e_"+item.getId())){
|
||||
tdEngineService.updateTagDeviceCode("e_"+item.getId(),item.getCode());
|
||||
tdEngineService.updateTagDeviceName("e_"+item.getId(),item.getName());
|
||||
if (tdEngineService.checkTableExist("e_" + item.getId())) {
|
||||
tdEngineService.updateTagDeviceCode("e_" + item.getId(), item.getCode());
|
||||
tdEngineService.updateTagDeviceName("e_" + item.getId(), item.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(delSysEquipmentList)) {
|
||||
// 删除设备
|
||||
sysEquipmentMapper.deleteBatchIds(delSysEquipmentList);
|
||||
for (SysEquipment item : delSysEquipmentList){
|
||||
for (SysEquipment item : delSysEquipmentList) {
|
||||
dataService.deviceModelMap.remove(item.getId().toString());
|
||||
//更新设备缓存
|
||||
cacheService.getEquipmentCache().removeDeviceCache(item.getId());
|
||||
@ -387,7 +397,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
@Override
|
||||
public SysGenExtProps creatSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto) {
|
||||
if (sysGenExtPropsDto.getId() == null){
|
||||
if (sysGenExtPropsDto.getId() == null) {
|
||||
throw new ServiceException("设备id不能为空");
|
||||
}
|
||||
SysGenExtProps sysEquipmentExtProps = new SysGenExtProps();
|
||||
@ -398,7 +408,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
@Override
|
||||
public SysGenExtProps updateSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto) {
|
||||
if (sysGenExtPropsDto.getId() == null){
|
||||
if (sysGenExtPropsDto.getId() == null) {
|
||||
throw new ServiceException("设备id不能为空");
|
||||
}
|
||||
SysGenExtProps sysEquipmentExtProps = new SysGenExtProps();
|
||||
@ -418,22 +428,95 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysEquipmentDocs upload(Long deviceId, String folderName, MultipartFile file) {
|
||||
public List<SysEquipmentDocs> upload(Long deviceId, String component, String folderName, List<MultipartFile> fileList) throws Exception {
|
||||
List<SysEquipmentDocs> result = new ArrayList<>();
|
||||
for (MultipartFile file : fileList) {
|
||||
DeviceInfoCache deviceInfoCache = equipmentCache.getDeviceInfoCacheById(deviceId);
|
||||
String parent = FileConstants.FILE_SEPARATOR +"风机图片"+ FileConstants.FILE_SEPARATOR + deviceInfoCache.getDeviceCode();
|
||||
String parent = FileConstants.FILE_SEPARATOR + "WindTurbine" + FileConstants.FILE_SEPARATOR + deviceInfoCache.getDeviceCode() + FileConstants.FILE_SEPARATOR + "pic";
|
||||
File scale = null;
|
||||
try {
|
||||
String url = minioViewsServcie.upload(minioAutoProperties.getPublicBucket(), parent, folderName, file);
|
||||
String fileName = url.substring(url.lastIndexOf("/"));
|
||||
scale = scale(file);
|
||||
String scaleFileName = scale.getName();
|
||||
String scaleName = scaleFileName.substring(scaleFileName.lastIndexOf("_") + 1);
|
||||
String scaleParent = FileConstants.FILE_SEPARATOR + "WindTurbine" + FileConstants.FILE_SEPARATOR + deviceInfoCache.getDeviceCode() + FileConstants.FILE_SEPARATOR + "thumbnailPic" + FileConstants.FILE_SEPARATOR + scaleName;
|
||||
minioViewsServcie.uploadTemFile(minioAutoProperties.getPublicBucket(), scale, scaleParent);
|
||||
String fileName = url.substring(url.lastIndexOf("/") + 1);
|
||||
SysEquipmentDocs sysEquipmentDocs = saveDocs(deviceId, component, fileName, url);
|
||||
SysEquipmentDocs sysEquipmentDocsScale = saveDocs(deviceId, component, scaleName, scaleParent);
|
||||
result.add(sysEquipmentDocs);
|
||||
result.add(sysEquipmentDocsScale);
|
||||
} catch (Exception e) {
|
||||
log.error("图片上传失败{}", e);
|
||||
} finally {
|
||||
if (scale != null && scale.exists()){
|
||||
scale.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysEquipmentDocs> getFileList(Long deviceId, String component) {
|
||||
QueryWrapper<SysEquipmentDocs> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("DEVICEID",deviceId);
|
||||
queryWrapper.eq("COMPONENT",component);
|
||||
return sysEquipmentDocsMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFileToSteam(String path, OutputStream stream) {
|
||||
minioViewsServcie.readFileToStream(path, stream);
|
||||
}
|
||||
|
||||
public File scale(MultipartFile file) throws IOException {
|
||||
// 获取原始文件名和文件类型
|
||||
String originalFileName = file.getOriginalFilename();
|
||||
String originalContentType = file.getContentType();
|
||||
|
||||
if (originalFileName == null || originalFileName.isEmpty()) {
|
||||
throw new IllegalArgumentException("文件名不能为空");
|
||||
}
|
||||
|
||||
if (originalContentType == null || originalContentType.isEmpty()) {
|
||||
throw new IllegalArgumentException("文件类型不能为空");
|
||||
}
|
||||
// 创建临时文件,名称基于原始文件名
|
||||
File tempFile = File.createTempFile("thumbnail_", "_" + originalFileName);
|
||||
InputStream inputStream = file.getInputStream();
|
||||
try {
|
||||
File mulFile = new File(System.getProperty("java.io.tmpdir") + "/" + file.getOriginalFilename());
|
||||
// 将MultipartFile写入临时文件
|
||||
file.transferTo(mulFile);
|
||||
// 生成缩略图
|
||||
ImgUtil.scale(mulFile, tempFile, 700, 700, null);
|
||||
} finally {
|
||||
IoUtil.close(inputStream);
|
||||
|
||||
}
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
public SysEquipmentDocs saveDocs(Long deviceId, String component,String fileName,String url){
|
||||
SysEquipmentDocs sysEquipmentDocs = new SysEquipmentDocs();
|
||||
sysEquipmentDocs.setDeviceId(deviceId);
|
||||
sysEquipmentDocs.setName(fileName);
|
||||
sysEquipmentDocs.setUrl(url);
|
||||
sysEquipmentDocs.setComponent(component);
|
||||
sysEquipmentDocs.setUpdateTime(new Date());
|
||||
SysEquipmentDocs sysEquipmentDocsInfo = sysEquipmentDocsMapper.selectById(deviceId);
|
||||
if (sysEquipmentDocsInfo == null){
|
||||
QueryWrapper<SysEquipmentDocs> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("url",url);
|
||||
SysEquipmentDocs sysEquipmentDocsInfo = sysEquipmentDocsMapper.selectOne(queryWrapper);
|
||||
if (sysEquipmentDocsInfo == null) {
|
||||
sysEquipmentDocsMapper.insert(sysEquipmentDocs);
|
||||
}else {
|
||||
} else {
|
||||
sysEquipmentDocs.setId(sysEquipmentDocsInfo.getId());
|
||||
sysEquipmentDocsMapper.updateById(sysEquipmentDocs);
|
||||
}
|
||||
return sysEquipmentDocs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -78,11 +78,11 @@ public class MinioViewsServcie {
|
||||
}
|
||||
|
||||
|
||||
public String upload(String bucketName, String path, String folderName,MultipartFile file) {
|
||||
public String upload(String bucketName, String path, String folderName, MultipartFile file) {
|
||||
String targetFile = null;
|
||||
try {
|
||||
// 上传一个空对象来模拟文件夹
|
||||
if (!StringUtils.isBlank(folderName)){
|
||||
if (!StringUtils.isBlank(folderName)) {
|
||||
targetFile = path + folderName + FileConstants.FILE_SEPARATOR;
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
|
||||
minioClient.putObject(
|
||||
@ -91,9 +91,8 @@ public class MinioViewsServcie {
|
||||
.object(targetFile)
|
||||
.stream(bais, 0, -1)
|
||||
.build());
|
||||
}
|
||||
else {
|
||||
targetFile= path +"/" + file.getOriginalFilename();
|
||||
} else {
|
||||
targetFile = path + "/" + file.getOriginalFilename();
|
||||
uploadFile(bucketName, file, targetFile, "application/octet-stream");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -114,7 +113,7 @@ public class MinioViewsServcie {
|
||||
*/
|
||||
public void uploadFile(String bucketName, MultipartFile file, String objectName, String contentType) throws Exception {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
try{
|
||||
try {
|
||||
minioClient.putObject(
|
||||
PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
@ -122,12 +121,35 @@ public class MinioViewsServcie {
|
||||
.contentType(contentType)
|
||||
.stream(inputStream, inputStream.available(), -1)
|
||||
.build());
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("minio文件上传失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void uploadTemFile(String bucketName, File file, String objectName) throws Exception {
|
||||
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file)) {
|
||||
minioClient.putObject(
|
||||
PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.contentType("application/octet-stream")
|
||||
.stream(fileInputStream, file.length(), -1)
|
||||
.build()
|
||||
);
|
||||
|
||||
|
||||
// 删除临时文件
|
||||
if (!file.delete()) {
|
||||
System.err.println("临时文件删除失败:" + file.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("生成缩略图或上传到 MinIO 失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//获取路径下的文件夹文件列表
|
||||
public List<FileNode> getFileTree(String directoryName) {
|
||||
List<FileNode> fileNodes = new ArrayList<>();
|
||||
@ -137,7 +159,7 @@ public class MinioViewsServcie {
|
||||
if (StringUtils.isBlank(directoryName)) {
|
||||
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).recursive(true).build();
|
||||
} else {
|
||||
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).prefix(directoryName+"/").recursive(true).build();
|
||||
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).prefix(directoryName + "/").recursive(true).build();
|
||||
}
|
||||
Iterable<Result<Item>> results = minioClient.listObjects(build);
|
||||
for (Result<Item> result : results) {
|
||||
@ -147,24 +169,23 @@ public class MinioViewsServcie {
|
||||
String size = FileUtil.readableFileSize(item.size());
|
||||
String relativePath = null;
|
||||
String[] parts = null;
|
||||
if (!StringUtils.isBlank(directoryName)){
|
||||
if (!StringUtils.isBlank(directoryName)) {
|
||||
relativePath = itemName.substring(directoryName.length());
|
||||
parts = relativePath.split("/");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
parts = itemName.split("/");
|
||||
}
|
||||
String lastModifyTime = null;
|
||||
DateTimeFormatter dateFormat =DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
if (!isDir){
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
||||
if (!isDir) {
|
||||
ZonedDateTime zonedDateTime = item.lastModified();
|
||||
lastModifyTime = zonedDateTime.format(dateFormat);
|
||||
}
|
||||
if (parts.length > 0) {
|
||||
String nodeName = parts[1];
|
||||
int type = isDir ? 0 : 1;
|
||||
itemName= isDir ? itemName.substring(0,itemName.lastIndexOf("/")) : itemName;
|
||||
FileNode node = new FileNode(nodeName, type,size,lastModifyTime,"/"+itemName);
|
||||
itemName = isDir ? itemName.substring(0, itemName.lastIndexOf("/")) : itemName;
|
||||
FileNode node = new FileNode(nodeName, type, size, lastModifyTime, "/" + itemName);
|
||||
if (!fileNodes.contains(node)) {
|
||||
fileNodes.add(node);
|
||||
}
|
||||
@ -178,15 +199,15 @@ public class MinioViewsServcie {
|
||||
|
||||
public void readFileToStream(String path, OutputStream stream) {
|
||||
|
||||
try ( GetObjectResponse res = minioClient.getObject(
|
||||
GetObjectArgs.builder().bucket(minioProperties.getBucket()).object(path).build())){
|
||||
try (GetObjectResponse res = minioClient.getObject(
|
||||
GetObjectArgs.builder().bucket(minioProperties.getBucket()).object(path).build())) {
|
||||
res.transferTo(stream);
|
||||
} catch (Exception e) {
|
||||
log.error("minio读取文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void download(String path, Path tempDir,HttpServletResponse httpServletResponse) {
|
||||
public void download(String path, Path tempDir, HttpServletResponse httpServletResponse) {
|
||||
|
||||
File tempFile = null;
|
||||
try (InputStream inputStream = minioClient.getObject(GetObjectArgs.builder()
|
||||
@ -202,7 +223,7 @@ public class MinioViewsServcie {
|
||||
|
||||
} finally {
|
||||
assert tempFile != null;
|
||||
if (tempFile.exists()){
|
||||
if (tempFile.exists()) {
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
@ -257,7 +278,7 @@ public class MinioViewsServcie {
|
||||
return total;
|
||||
}
|
||||
|
||||
public InputStream getFileStream(String url){
|
||||
public InputStream getFileStream(String url) {
|
||||
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
|
@ -109,6 +109,6 @@ tdengine:
|
||||
minio:
|
||||
url: http://192.168.109.187:9000
|
||||
bucket: das
|
||||
publicBucket: das-public
|
||||
publicBucket: das-dock
|
||||
accessKey: das
|
||||
secretKey: zaq12WSX
|
Binary file not shown.
BIN
document/风电场数据采集系统使用手册v1.1.docx
Normal file
BIN
document/风电场数据采集系统使用手册v1.1.docx
Normal file
Binary file not shown.
@ -363,36 +363,6 @@ const StatusListData = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
// 添加响应式属性以存储故障代码字典
|
||||
/*const malFunctionEnums = ref<{ [key: string]: { [code: string]: string } }>({});
|
||||
|
||||
const requestedParams = new Set<string>();
|
||||
const failedRequests = new Set<string>();
|
||||
|
||||
const fetchData = async (item: any) => {
|
||||
const key = `${item.madeinFactory}-${item.model}`;
|
||||
|
||||
if (requestedParams.has(key)) {
|
||||
return;
|
||||
}
|
||||
requestedParams.add(key);
|
||||
|
||||
try {
|
||||
const response = await queryfaultCodeDict({ madeinfactory: item.madeinFactory, model: item.model });
|
||||
if (response.code === 200) {
|
||||
const data: any = {};
|
||||
response.data.forEach((item: any) => {
|
||||
data[item.code] = item.description;
|
||||
});
|
||||
malFunctionEnums.value[key] = data;
|
||||
} else {
|
||||
console.warn('查询故障代码字典失败:', response.message);
|
||||
failedRequests.add(key);
|
||||
}
|
||||
} catch (error) {
|
||||
failedRequests.add(key);
|
||||
}
|
||||
};*/
|
||||
|
||||
|
||||
let autoUpdateForSecondTimer: any = null
|
||||
|
@ -411,57 +411,6 @@ const getSafeImagePath = (item, type) => {
|
||||
|
||||
};
|
||||
|
||||
/*const getFaultDescription=(item)=>{
|
||||
const key = `${item.madeinFactory}-${item.model}`;
|
||||
if (failedRequests.has(key)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!malFunctionEnums[key]) {
|
||||
fetchData(item); // 如果还没有请求过,则发起请求
|
||||
// return item.attributeMap.firsttriggeredcode;
|
||||
}
|
||||
|
||||
let firsttriggeredcode = item.attributeMap.firsttriggeredcode;
|
||||
if (malFunctionKeys.includes('FirstTriggeredCode') && malFunctionEnums[key]) {
|
||||
if(firsttriggeredcode==0){
|
||||
return ''
|
||||
}else{
|
||||
firsttriggeredcode = malFunctionEnums[key][firsttriggeredcode] ?? '';
|
||||
}
|
||||
}
|
||||
return firsttriggeredcode;
|
||||
}
|
||||
|
||||
let malFunctionEnums: { [key: string]: { [code: string]: string } } = {};
|
||||
const requestedParams = new Set<string>();
|
||||
const failedRequests = new Set<string>();
|
||||
|
||||
const fetchData = async (item: any) => {
|
||||
const key = `${item.madeinFactory}-${item.model}`;
|
||||
|
||||
if (requestedParams.has(key)) {
|
||||
return;
|
||||
}
|
||||
requestedParams.add(key);
|
||||
|
||||
try {
|
||||
const response = await queryfaultCodeDict({ madeinfactory: item.madeinFactory, model: item.model });
|
||||
if (response.code === 200) {
|
||||
const data: any = {};
|
||||
response.data.forEach((item: any) => {
|
||||
data[item.code] = item.description;
|
||||
});
|
||||
malFunctionEnums[key] = data;
|
||||
} else {
|
||||
console.warn('查询故障代码字典失败:', response.message);
|
||||
failedRequests.add(key);
|
||||
}
|
||||
} catch (error) {
|
||||
failedRequests.add(key);
|
||||
}
|
||||
};*/
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
@ -513,15 +513,13 @@ const fileName = ref('')
|
||||
const warningInfo = ref()
|
||||
const previewFileDialogVisible = ref(false)
|
||||
const readFile = (data: tableItemData) => {
|
||||
fileName.value = data.name.slice(24)
|
||||
fileName.value = activeName.value === 'malFunction' ? data.name.slice(24) : data.name
|
||||
previewFileDialogVisible.value = true
|
||||
getFileKeyEnum().finally(() => {
|
||||
getFileData(data.path)
|
||||
.then((res) => {
|
||||
// warningInfo.value = res.data.faultTime ? dayjs(res.data.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS') : ''
|
||||
|
||||
previewChartData = res.data.dataCurve
|
||||
const attrName = Object.keys(res.data.dataCurve)
|
||||
.then((res: { data: any; faultTime?: any }) => {
|
||||
previewChartData = res.data
|
||||
const attrName = Object.keys(res.data)
|
||||
const data: any = []
|
||||
let hasAddFaultTime = false
|
||||
attrName.forEach((item) => {
|
||||
@ -529,8 +527,8 @@ const readFile = (data: tableItemData) => {
|
||||
let timeStamp: any = []
|
||||
previewChartData.TimeStamp = previewChartData.TimeStamp.map((item: any) => {
|
||||
const parseTime = dayjs(item).format('YYYY-MM-DD HH:mm:ss.SSS')
|
||||
if (!hasAddFaultTime && res.data?.faultTime && item > res.data.faultTime) {
|
||||
const parseFaultTime = dayjs(res.data.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS')
|
||||
if (!hasAddFaultTime && res?.faultTime && item > res?.faultTime) {
|
||||
const parseFaultTime = dayjs(res.faultTime).format('YYYY-MM-DD HH:mm:ss.SSS')
|
||||
warningInfo.value = parseFaultTime
|
||||
timeStamp.push(parseFaultTime)
|
||||
hasAddFaultTime = true
|
||||
@ -694,6 +692,7 @@ const createSeriresData = () => {
|
||||
const initPreviewChart = () => {
|
||||
const chart = previewChartInstance ?? echarts.init(previewChartRef.value)
|
||||
const series = createSeriresData()
|
||||
|
||||
const option = {
|
||||
grid: {
|
||||
top: 50,
|
||||
@ -791,7 +790,9 @@ const initPreviewChart = () => {
|
||||
color: '#73767a',
|
||||
},
|
||||
},
|
||||
series: [
|
||||
series:
|
||||
activeName.value === 'malFunction'
|
||||
? [
|
||||
...series,
|
||||
{
|
||||
type: 'line',
|
||||
@ -811,7 +812,8 @@ const initPreviewChart = () => {
|
||||
animation: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
]
|
||||
: series,
|
||||
}
|
||||
chart.setOption(option)
|
||||
previewChartInstance = chart
|
||||
@ -823,11 +825,15 @@ const getFileData = (url: string) => {
|
||||
return previewFileReq({
|
||||
deviceCode: curTreeData.value.code,
|
||||
url: url,
|
||||
}).then((res) => {
|
||||
return { data: res.data.dataCurve, faultTime: res.data?.faultTime }
|
||||
})
|
||||
} else if (activeName.value === 'logManage') {
|
||||
return previewLogFileReq({
|
||||
deviceCode: curTreeData.value.code,
|
||||
url: url,
|
||||
}).then((res) => {
|
||||
return { data: res.data }
|
||||
})
|
||||
}
|
||||
return Promise.reject()
|
||||
|
@ -438,7 +438,7 @@ const calculateAverages = (data: any) => {
|
||||
|
||||
if (count > 0) {
|
||||
let averagePower = sumPower / count
|
||||
result.push([windSpeed + interval, averagePower])
|
||||
result.push([windSpeed + interval, 2, getCutDecimalsValue(averagePower, 2)])
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user