feat: 增加采集时间

dev
huangfeng 4 months ago
parent 8e5f225267
commit d9dcc76d62

@ -0,0 +1,17 @@
DROP TABLE IF EXISTS `ied_dl_record`;
CREATE TABLE `ied_dl_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`config_id` int(11) DEFAULT NULL,
`remote_path` varchar(200) DEFAULT NULL COMMENT '源路径',
`filename` varchar(200) DEFAULT NULL COMMENT '文件名',
`path` varchar(200) DEFAULT NULL COMMENT '本地路径',
`create_time` datetime DEFAULT NULL,
`d_time` datetime DEFAULT NULL,
`dev_id` int(11) DEFAULT NULL COMMENT '装置ID',
`type_id` int(11) DEFAULT NULL COMMENT '类型id',
`data` mediumtext,
PRIMARY KEY (`id`),
KEY `idxDev` (`dev_id`,`d_time`),
KEY `idxConfig` (`config_id`,`d_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -1,9 +0,0 @@
ALTER TABLE `ied_dl_record`
ADD COLUMN `dev_id` INT(11) NULL DEFAULT NULL COMMENT '装置ID' AFTER `create_time`,
ADD COLUMN `type_id` INT(11) NULL DEFAULT NULL COMMENT '类型id' AFTER `dev_id`,
ADD COLUMN `data` MEDIUMTEXT NULL AFTER `type_id`;
ALTER TABLE `ied_dl_record`
ADD INDEX `idxDev` (`dev_id` ASC, `create_time` ASC);
ALTER TABLE `ied_dl_record`
ADD INDEX `idxConfig` (`config_id` ASC, `create_time` ASC);

@ -1,6 +1,5 @@
package com.xydl.cac.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xydl.cac.model.spectrogram.SpectrogramModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -12,7 +11,6 @@ import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@Builder
@AllArgsConstructor
@ -43,6 +41,10 @@ public class IedDlRecord {
@Column(name = "filename")
private String filename;
@ApiModelProperty("采集时间")
@Column(name = "d_time")
private Date dTime;
@ApiModelProperty("创建时间")
@Column(name = "create_time")
private Date createTime;

@ -226,7 +226,6 @@ public class IEDCollectService {
String localFullPath = _bizConfig.getDatapath() + relativePath;
iecClient.getFile(record.getRemotePath(), localFullPath, config.getTodel());
record.setPath(_bizConfig.getDataNginxPath() + relativePath);
record.setCreateTime(new Date());
log.info("采集到" + record.getRemotePath());
_spectrogramHandler.processFile(record);
_dlRecordService.add(record);

@ -38,18 +38,18 @@ public class IedDlRecordServiceImpl implements IedDlRecordService {
Predicate predicate = builder.conjunction();
if (configId != null) {
predicate.getExpressions().add(builder.equal(root.get("configId"), configId));
query.orderBy(builder.desc(root.get("createTime")));
query.orderBy(builder.desc(root.get("dTime")));
} else if (devId != null) {
predicate.getExpressions().add(builder.equal(root.get("devId"), devId));
query.orderBy(builder.desc(root.get("createTime")));
query.orderBy(builder.desc(root.get("dTime")));
} else {
query.orderBy(builder.desc(root.get("id")));
}
if (startTime != null) {
predicate.getExpressions().add(builder.greaterThan(root.get("createTime"), startTime));
predicate.getExpressions().add(builder.greaterThan(root.get("dTime"), startTime));
}
if (endTime != null) {
predicate.getExpressions().add(builder.lessThanOrEqualTo(root.get("createTime"), endTime));
predicate.getExpressions().add(builder.lessThanOrEqualTo(root.get("dTime"), endTime));
}
return predicate;
};

@ -4,11 +4,14 @@ import com.xydl.cac.config.BizConfig;
import com.xydl.cac.entity.IedDlRecord;
import com.xydl.cac.entity.constants.Constants;
import com.xydl.cac.model.spectrogram.SouthYsp;
import com.xydl.cac.util.DataUtil;
import com.xydl.cac.util.DateUtil;
import com.xydl.cac.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
@Service
@Slf4j
@ -30,6 +33,13 @@ public class SpectrogramHandler {
SouthYsp model = processorYsp.process(localFilePath);
String json = JSONUtil.object2Json(model);
record.setData(json);
record.setCreateTime(new Date());
try {
String str = String.valueOf(model.getCreateTime());
Date dtime = DateUtil.parse(str, "yyyyMMddHHmmss");
record.setDTime(dtime);
} catch (Exception ignore) {
}
log.info("解析油色谱谱图文件成功");
} else {
log.error("缺少该类型" + record.getTypeId() + "的谱图处理模块");

Loading…
Cancel
Save