This commit is contained in:
zhouhuang 2024-12-16 15:48:00 +08:00
commit c27b4a359b
7 changed files with 40 additions and 27 deletions

View File

@ -216,7 +216,7 @@ public class SysIotModelController {
return R.success();
}
/** 物模型导出 */
/** 物模型属性导出 */
@PostMapping("/export")
public void exportSysIotModel(@RequestBody SysIotModelDto sysIotModelDto, HttpServletRequest request, HttpServletResponse response) {
@ -227,7 +227,7 @@ public class SysIotModelController {
}
/** 物模型导入 */
/** 物模型属性导入 */
@PostMapping("/import")
public R<Void> importSysIotModel(String id, @RequestParam("file") MultipartFile file) throws IOException {

View File

@ -77,5 +77,5 @@ public class SysIotModelFieldDto implements Serializable {
private String stateDesc;
private Integer confidential;
}

View File

@ -70,4 +70,6 @@ public class SysIotModelFieldVo {
private String stateDesc;
private Integer confidential;
}

View File

@ -111,4 +111,11 @@ public class SysIotModelField extends BaseEntity {
*/
@TableField("statedesc")
private String stateDesc;
/**
* 是否为敏感数据
*/
@TableField("confidential")
private Integer confidential;
}

View File

@ -311,8 +311,9 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put("dataType", "*数据类型");
map.put("visible", "是否可见0不可见1可见");
map.put("highSpeed", "*属性频度0低频属性1高频属性");
map.put("level","离散量级别:0提示;1告警;2故障");
map.put("stateDesc","告警级别描述");
map.put("level", "离散量级别:0提示;1告警;2故障");
map.put("stateDesc", "告警级别描述");
map.put("confidential","是否为敏感数据(0非敏感数据1敏感数据)");
sheetDTO.setSheetName("物模型属性");
sheetDTO.setFieldAndAlias(map);
sheetDTO.setCollection(sysIotModelFieldVoList);
@ -460,7 +461,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);
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "新增低频TD超级表字段," + "表名l_" + sysIotModel.getIotModelCode() + ",字段:" + map);
addModelFieldCache(lowCreateList.get(i));
}
}
@ -476,7 +477,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);
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "新增低频TD超级表字段," + "表名h_" + sysIotModel.getIotModelCode() + ",字段:" + map);
addModelFieldCache(highCreateList.get(i));
}
}
@ -514,10 +515,13 @@ public class SysIotModelServiceImpl implements SysIotModelService {
private static void buildFieldInfo(String iotModelId, List<Object> row, SysIotModelField field) {
//参数校验
boolean allNotEmpty = ObjectUtil.isAllNotEmpty(row.get(3), row.get(4), row.get(5), row.get(7), row.get(9), row.get(11));
boolean allNotEmpty = ObjectUtil.isAllNotEmpty(row.get(3), row.get(4), row.get(5), row.get(7), row.get(9), row.get(11), row.get(14));
if (!allNotEmpty) {
throw new ServiceException("字段不可为空请检查excel文件{}" + row);
}
if (!(row.get(14).toString().equals("0") || row.get(14).toString().equals("1"))){
throw new ServiceException("参数是否为敏感字段不符合规范请输入0或者1");
}
field.setAttributeCode(row.get(3).toString());
field.setAttributeName(row.get(4).toString());
field.setAttributeType(Integer.valueOf(row.get(5).toString()));
@ -530,6 +534,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
field.setHighSpeed(Integer.valueOf(row.get(11).toString()));
field.setLevel(ObjectUtil.isEmpty(row.get(12)) ? null : Integer.valueOf(row.get(12).toString()));
field.setStateDesc(ObjectUtil.isEmpty(row.get(13)) ? null : row.get(13).toString());
field.setConfidential(Integer.valueOf(row.get(14).toString()));
field.setIotModelId(Long.valueOf(iotModelId));
}
@ -544,7 +549,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());
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "创建计算超级表" + "c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
} else {
//创建type为138 139 140的超级表
//如果新增的是第一条记录 创建tdengine超级表 分为高频和低频
@ -559,7 +564,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建低频超级表
tdEngineService.createStable(sysIotModel.getIotModelCode(), "l_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","创建低频TD超级表"+"l_" +sysIotModel.getIotModelCode());
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "创建低频TD超级表" + "l_" + sysIotModel.getIotModelCode());
}
if (sysIotModelField.getHighSpeed() == 1) {
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -567,7 +572,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建高频超级表
tdEngineService.createStable(sysIotModel.getIotModelCode(), "h_", map);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","创建高频TD超级表"+"h_" +sysIotModel.getIotModelCode());
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "创建高频TD超级表" + "h_" + sysIotModel.getIotModelCode());
}
} else {
//stable已经存在,新增stable列
@ -577,7 +582,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);
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "新增低频TD超级表字段," + "表名l_" + sysIotModel.getIotModelCode() + ",字段:" + map);
}
if (sysIotModelField.getHighSpeed() == 1) {
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -585,7 +590,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);
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "新增高频TD超级表字段," + "表名h_" + sysIotModel.getIotModelCode() + ",字段:" + map);
}
}
}
@ -601,7 +606,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());
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "删除TD超级表" + "c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
} else {
String stableName = null;
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@ -617,12 +622,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());
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "删除TD超级表" + stableName + "中字段:" + sysIotModelField.getAttributeCode());
}
//物模型属性只剩下最后一个删除表
if (CollectionUtils.isNotEmpty(sysIotModelFields) && sysIotModelFields.size() == 1) {
tdEngineService.deleteStable(stableName);
sysRecordLogService.createRecordLog("/系统管理/物模型配置","删除TD超级表"+ stableName);
sysRecordLogService.createRecordLog("/系统管理/物模型配置", "删除TD超级表" + stableName);
}
}
@ -635,13 +640,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
Map<String, String> fieldCodeNameMap = dataService.fieldCodeNameMap.get(modelCode);
if (fieldCodeNameMap == null) {
Map<String, String> fieldCodeName = new HashMap<>();
fieldCodeName.put(sysIotModelField.getAttributeCode(),sysIotModelField.getAttributeName());
dataService.fieldCodeNameMap.put(modelCode,fieldCodeName);
}
else {
fieldCodeName.put(sysIotModelField.getAttributeCode(), sysIotModelField.getAttributeName());
dataService.fieldCodeNameMap.put(modelCode, fieldCodeName);
} else {
fieldCodeNameMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getAttributeName());
}
if (sysIotModelField.getLevel() != null){
if (sysIotModelField.getLevel() != null) {
Map<String, Integer> levelMap = dataService.eventLevelMap.get(modelCode);
if (levelMap == null) {
Map<String, Integer> calMap = new HashMap<>();
@ -652,7 +656,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
}
}
if (sysIotModelField.getStateDesc() != null){
if (sysIotModelField.getStateDesc() != null) {
Map<String, String> stateDescMap = dataService.stateDescMap.get(modelCode);
if (stateDescMap == null) {
Map<String, String> calMap = new HashMap<>();
@ -710,10 +714,10 @@ public class SysIotModelServiceImpl implements SysIotModelService {
String modelCode = dataService.iotModelMap.get(sysIotModelField.getIotModelId().toString());
Map<String, String> fieldCodeName = dataService.fieldCodeNameMap.get(modelCode);
fieldCodeName.remove(sysIotModelField.getAttributeCode());
if (sysIotModelField.getLevel() != null){
if (sysIotModelField.getLevel() != null) {
dataService.eventLevelMap.remove(sysIotModelField.getAttributeCode());
}
if (sysIotModelField.getStateDesc() != null){
if (sysIotModelField.getStateDesc() != null) {
dataService.stateDescMap.remove(sysIotModelField.getAttributeCode());
}
if (sysIotModelField.getAttributeType() == 199) {

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("Tracelog",code,startTime,endTime);
List<FileNode> result = faultRecorderService.getDirOrFileList("Statuscode",code,startTime,endTime);
return R.success(result);
}

View File

@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
/**
* 故障录波controller
* 运行日志controller
*/
@Slf4j
@RequestMapping("/api/plc")
@ -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("Statuscode",code,startTime,endTime);
List<FileNode> result = plcLogService.getDirOrFileList("Tracelog",code,startTime,endTime);
return R.success(result);
}