plc,故障日志修改

This commit is contained in:
huguanghan 2024-12-09 17:00:29 +08:00
parent 36bcbc0349
commit fbba27eb92
8 changed files with 108 additions and 5 deletions

View File

@ -28,6 +28,7 @@ import com.das.modules.equipment.mapper.SysIotModelMapper;
import com.das.modules.equipment.mapper.SysIotModelServiceMapper;
import com.das.modules.equipment.service.SysIotModelService;
import com.das.modules.data.service.TDEngineService;
import com.das.modules.record.service.SysRecordLogService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@ -61,6 +62,9 @@ public class SysIotModelServiceImpl implements SysIotModelService {
@Autowired
private DataServiceImpl dataService;
@Autowired
SysRecordLogService sysRecordLogService;
public SysIotModelVo creatSysIotModel(SysIotModelDto sysIotModelDto) {
SysIotModel sysIotModel = new SysIotModel();
BeanCopyUtils.copy(sysIotModelDto, sysIotModel);
@ -453,6 +457,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建低频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "l_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","新增低频TD超级表字段"+"表名l_" +sysIotModel.getIotModelCode()+",字段:"+map);
addModelFieldCache(lowCreateList.get(i));
}
}
@ -468,6 +473,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建高频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "h_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","新增低频TD超级表字段"+"表名h_" +sysIotModel.getIotModelCode()+",字段:"+map);
addModelFieldCache(highCreateList.get(i));
}
}
@ -535,6 +541,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
if (sysIotModelField.getAttributeType() == 199) {
String modelCode = dataService.iotModelMap.get(sysIotModelField.getIotModelId().toString());
tdEngineService.createCalStable(modelCode, sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
sysRecordLogService.createRecordLog("/系统管理/物模型配置","创建计算超级表"+"c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
} else {
//创建type为138 139 140的超级表
//如果新增的是第一条记录 创建tdengine超级表 分为高频和低频
@ -549,6 +556,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建低频超级表
tdEngineService.createStable(sysIotModel.getIotModelCode(), "l_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","创建低频TD超级表"+"l_" +sysIotModel.getIotModelCode());
}
if (sysIotModelField.getHighSpeed() == 1) {
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -556,6 +564,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建高频超级表
tdEngineService.createStable(sysIotModel.getIotModelCode(), "h_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","创建高频TD超级表"+"h_" +sysIotModel.getIotModelCode());
}
} else {
//stable已经存在,新增stable列
@ -565,6 +574,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建低频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "l_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","新增低频TD超级表字段"+"表名l_" +sysIotModel.getIotModelCode()+",字段:"+map);
}
if (sysIotModelField.getHighSpeed() == 1) {
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -572,6 +582,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建高频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "h_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","新增高频TD超级表字段"+"表名h_" +sysIotModel.getIotModelCode()+",字段:"+map);
}
}
}
@ -587,6 +598,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
Long iotModelId = sysIotModelField.getIotModelId();
String modelCode = dataService.iotModelMap.get(iotModelId.toString());
tdEngineService.deleteStable("c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
sysRecordLogService.createRecordLog("/系统管理/物模型配置","删除TD超级表"+"c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
} else {
String stableName = null;
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -602,10 +614,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
List<SysIotModelField> sysIotModelFields = sysIotModelFieldMapper.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(sysIotModelFields) && sysIotModelFields.size() > 1) {
tdEngineService.deleteColumn(stableName, sysIotModelField.getAttributeCode());
sysRecordLogService.createRecordLog("/系统管理/物模型配置","删除TD超级表"+ stableName +"中字段:"+ sysIotModelField.getAttributeCode());
}
//物模型属性只剩下最后一个删除表
if (CollectionUtils.isNotEmpty(sysIotModelFields) && sysIotModelFields.size() == 1) {
tdEngineService.deleteStable(stableName);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","删除TD超级表"+ stableName);
}
}

View File

@ -51,7 +51,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("Tracelog",code,startTime,endTime);
return R.success(result);
}

View File

@ -135,9 +135,9 @@ public class MinioViewsServcie {
try {
if (StringUtils.isBlank(directoryName)) {
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).recursive(false).build();
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).recursive(true).build();
} else {
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).prefix(directoryName+"/").recursive(false).build();
build = ListObjectsArgs.builder().bucket(minioProperties.getBucket()).prefix(directoryName+"/").recursive(true).build();
}
Iterable<Result<Item>> results = minioClient.listObjects(build);
for (Result<Item> result : results) {
@ -161,7 +161,7 @@ public class MinioViewsServcie {
lastModifyTime = zonedDateTime.format(dateFormat);
}
if (parts.length > 0) {
String nodeName = parts[1];
String nodeName = parts[2];
int type = isDir ? 0 : 1;
itemName= isDir ? itemName.substring(0,itemName.lastIndexOf("/")) : itemName;
FileNode node = new FileNode(nodeName, type,size,lastModifyTime,"/"+itemName);

View File

@ -44,7 +44,7 @@ public class PlcLogsController {
String code = jsonObject.getString("deviceCode");
String startTime = jsonObject.getString("startTime");
String endTime = jsonObject.getString("endTime");
List<FileNode> result = plcLogService.getDirOrFileList("日志",code,startTime,endTime);
List<FileNode> result = plcLogService.getDirOrFileList("Statuscode",code,startTime,endTime);
return R.success(result);
}

View File

@ -0,0 +1,40 @@
package com.das.modules.record.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@TableName("sys_record_log")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysRecordLog {
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@TableField("user_id")
private String userId;
@TableField("user_name")
private String username;
@TableField("group_by")
private String groupBy;
@TableField("ip_address")
private String ipAddress;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("opt_time")
private Date optTime;
@TableField("opt_desc")
private String optDesc;
}

View File

@ -0,0 +1,10 @@
package com.das.modules.record.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.das.modules.record.domain.SysRecordLog;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRecordLogMapper extends BaseMapper<SysRecordLog> {
}

View File

@ -0,0 +1,7 @@
package com.das.modules.record.service;
public interface SysRecordLogService {
void createRecordLog(String group, String desc);
}

View File

@ -0,0 +1,32 @@
package com.das.modules.record.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.das.common.config.SessionUtil;
import com.das.modules.auth.domain.vo.SysUserVo;
import com.das.modules.plc.mapper.SysRunLogDescMapper;
import com.das.modules.record.domain.SysRecordLog;
import com.das.modules.record.mapper.SysRecordLogMapper;
import com.das.modules.record.service.SysRecordLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class SysRecordLogServiceImpl implements SysRecordLogService {
@Autowired
private SysRecordLogMapper sysRecordLogMapper;
@Override
public void createRecordLog(String group, String desc) {
SysRecordLog sysRecordLog = new SysRecordLog();
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
sysRecordLog.setUsername(sysUserVo.getAccount());
sysRecordLog.setUserId(sysUserVo.getAccount());
sysRecordLog.setOptTime(new Date());
sysRecordLog.setGroupBy(group);
sysRecordLog.setOptDesc(desc);
sysRecordLogMapper.insert(sysRecordLog);
}
}