故障录波文件修改
This commit is contained in:
parent
2f665e5d3e
commit
86e9fb1efc
@ -141,6 +141,6 @@ public class SysEquipment extends BaseEntity {
|
||||
/**
|
||||
* 故障录波格式
|
||||
*/
|
||||
@TableField(value = "fdr_format")
|
||||
private String fdrFormat;
|
||||
@TableField(value = "options")
|
||||
private String options;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class FaultRecorderController {
|
||||
String code = jsonObject.getString("deviceCode");
|
||||
String startTime = jsonObject.getString("startTime");
|
||||
String endTime = jsonObject.getString("endTime");
|
||||
List<FileNode> result = faultRecorderService.getDirOrFileList(code,startTime,endTime);
|
||||
List<FileNode> result = faultRecorderService.getDirOrFileList("故障录波",code,startTime,endTime);
|
||||
return R.success(result);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.das.modules.fdr.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FileParseConfig {
|
||||
private FdrFormatVo fdrFormat;
|
||||
|
||||
private FdrFormatVo plcFormat;
|
||||
}
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FaultRecorderService {
|
||||
List<FileNode> getDirOrFileList(String name,String startTime, String endTime);
|
||||
List<FileNode> getDirOrFileList(String fileType,String name,String startTime, String endTime);
|
||||
|
||||
void download(String path, HttpServletResponse httpServletResponse) throws IOException;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||
import com.das.modules.fdr.config.MinioProperties;
|
||||
import com.das.modules.fdr.domain.FileNode;
|
||||
import com.das.modules.fdr.domain.vo.FdrFormatVo;
|
||||
import com.das.modules.fdr.domain.vo.FileParseConfig;
|
||||
import com.das.modules.fdr.service.FaultRecorderService;
|
||||
import com.das.modules.fdr.service.MinioViewsServcie;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
@ -47,11 +48,11 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<FileNode> getDirOrFileList(String name, String startTime, String endTime) {
|
||||
public List<FileNode> getDirOrFileList(String fileType,String name, String startTime, String endTime) {
|
||||
List<FileNode> fileResult = new ArrayList<>();
|
||||
List<String> monthsBetween = getMonthsBetween(startTime, endTime);
|
||||
for (String item : monthsBetween) {
|
||||
String directoryName = name + FileConstants.FILE_SEPARATOR + item.substring(0, item.indexOf("-")) + FileConstants.FILE_SEPARATOR + item.substring(item.indexOf("-") + 1);
|
||||
String directoryName = name + FileConstants.FILE_SEPARATOR + fileType + FileConstants.FILE_SEPARATOR + item.substring(0, item.indexOf("-")) + FileConstants.FILE_SEPARATOR + item.substring(item.indexOf("-") + 1);
|
||||
List<FileNode> fileTree = minioViewsServcie.getFileTree(directoryName);
|
||||
fileResult.addAll(fileTree);
|
||||
}
|
||||
@ -106,12 +107,14 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
|
||||
throw new ServiceException("设备不存在,请选择正确设备");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(sysEquipment.getFdrFormat())){
|
||||
throw new ServerException("请添加设备故障录波配置");
|
||||
if (StringUtils.isBlank(sysEquipment.getOptions())){
|
||||
throw new ServerException("请添加设备文件解析配置");
|
||||
}
|
||||
FileParseConfig fileParseConfig = JSON.parseObject(sysEquipment.getOptions(), FileParseConfig.class);
|
||||
FdrFormatVo fdrFormatVo = fileParseConfig.getFdrFormatVo();
|
||||
if (fdrFormatVo == null){
|
||||
throw new ServerException("请添加故障录波配置");
|
||||
}
|
||||
FdrFormatVo fdrFormatVo = JSON.parseObject(sysEquipment.getFdrFormat(), FdrFormatVo.class);
|
||||
|
||||
|
||||
// 解析文件内容
|
||||
resultMap = parseFile(fileStream, fdrFormatVo.getTimeFormat(), fdrFormatVo.getDelimiter(), fdrFormatVo.getValidStartLine());
|
||||
|
||||
@ -123,12 +126,19 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
|
||||
|
||||
@Override
|
||||
public void updateFdrConfig(SysEquipment sysEquipment) {
|
||||
String options = sysEquipment.getOptions();
|
||||
FileParseConfig fdrConfig = JSON.parseObject(options, FileParseConfig.class);
|
||||
SysEquipment equipment = sysEquipmentMapper.selectById(sysEquipment.getId());
|
||||
//合并配置
|
||||
if (StringUtils.isNotEmpty(equipment.getOptions())){
|
||||
FileParseConfig allConfig = JSON.parseObject(equipment.getOptions(), FileParseConfig.class);
|
||||
allConfig.setFdrFormatVo(fdrConfig.getFdrFormatVo());
|
||||
sysEquipment.setOptions(JSON.toJSONString(allConfig));
|
||||
}
|
||||
sysEquipmentMapper.updateById(sysEquipment);
|
||||
}
|
||||
|
||||
public Map<String, List<Object>> parseFile(InputStream inputStream, String timeFormat, String delimiter, int validStartLine) {
|
||||
|
||||
|
||||
List<List<String>> result = new ArrayList<>();
|
||||
Map<String, List<Object>> stringListMap = null;
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
@ -186,8 +196,6 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long convertToTimestamp(String time, String pattern) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
return sdf.parse(time).getTime();
|
||||
|
Loading…
Reference in New Issue
Block a user