模拟批量告警数据逻辑
This commit is contained in:
parent
187e2d394f
commit
19b44e2232
@ -4,8 +4,10 @@ import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
|||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.yfd.platform.utils.SecurityUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,6 +28,11 @@ public class AlgorithmDeviceServiceImpl extends ServiceImpl<AlgorithmDeviceMappe
|
|||||||
***********************************/
|
***********************************/
|
||||||
@Override
|
@Override
|
||||||
public boolean batchAddAlgorithmDevice(List<AlgorithmDevice> algorithmDeviceList) {
|
public boolean batchAddAlgorithmDevice(List<AlgorithmDevice> algorithmDeviceList) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
algorithmDeviceList.forEach(a -> {
|
||||||
|
a.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||||
|
a.setLastmodifydate(now);
|
||||||
|
});
|
||||||
return this.saveOrUpdateBatch(algorithmDeviceList);
|
return this.saveOrUpdateBatch(algorithmDeviceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.beanit.iec61850bean.BdaBoolean;
|
|||||||
import com.beanit.iec61850bean.BdaTimestamp;
|
import com.beanit.iec61850bean.BdaTimestamp;
|
||||||
import com.yfd.platform.component.WebSocketServer;
|
import com.yfd.platform.component.WebSocketServer;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.modules.auxcontrol.domain.AnalogData;
|
||||||
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
||||||
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
|
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
|
||||||
import com.yfd.platform.modules.basedata.domain.DeviceChannel;
|
import com.yfd.platform.modules.basedata.domain.DeviceChannel;
|
||||||
@ -292,37 +293,35 @@ public class AlarmLogController {
|
|||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/createAlarmData")
|
|
||||||
@ApiOperation("生成报警")
|
|
||||||
public ResponseResult createAlarmData(String from, String type, String slaveIp, String address, String value) {
|
|
||||||
|
|
||||||
deviceWorkDataService.insertData(from, slaveIp, address, value, getCurrentTime());
|
|
||||||
alarmLogService.doAlaramRecord(from, type, slaveIp, address, value);
|
|
||||||
// alarmLogService.doAlaramRecord("IEC61850", "yx", "192.168.1.1", "10", "2");
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
public static String getCurrentTime() {
|
public static String getCurrentTime() {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
return sdf.format(new Date());
|
return sdf.format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sendAnalogData")
|
@PostMapping("/sendAnalogData")
|
||||||
@ApiOperation("批量发送数据")
|
@ApiOperation("批量发送数据")
|
||||||
public ResponseResult sendAnalogData(String from, String type, String slaveIp, String address, String value) {
|
public ResponseResult sendAnalogData(@RequestBody List<AnalogData> analogDataList) {
|
||||||
if ("yc".equals(type)) {
|
for (AnalogData analogData : analogDataList) {
|
||||||
|
if ("yc".equals(analogData.getType())) {
|
||||||
//更新信号数据值
|
//更新信号数据值
|
||||||
deviceSignalMapper.updateDeviceSignalValue_yc(address, value, getCurrentTime());
|
deviceSignalMapper.updateDeviceSignalValue_yc(analogData.getAddress(), analogData.getValue(),
|
||||||
|
getCurrentTime());
|
||||||
//插入历史数据
|
//插入历史数据
|
||||||
deviceWorkDataService.insertData("IEC61850", null, address, value, getCurrentTime());
|
deviceWorkDataService.insertData("IEC61850", null, analogData.getAddress(), analogData.getValue(),
|
||||||
|
getCurrentTime());
|
||||||
//执行报警处理
|
//执行报警处理
|
||||||
alarmLogService.doAlaramRecord("IEC61850", "yc", null, address, value);
|
alarmLogService.doAlaramRecord("IEC61850", "yc", null, analogData.getAddress(), analogData.getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
if ("yx".equals(type)) {
|
if ("yx".equals(analogData.getType())) {
|
||||||
//更新信号状态
|
//更新信号状态
|
||||||
deviceSignalMapper.updateDeviceSignalValue_yx(address, value, getCurrentTime());
|
deviceSignalMapper.updateDeviceSignalValue_yx(analogData.getAddress(), analogData.getValue(),
|
||||||
|
getCurrentTime());
|
||||||
//执行报警处理:生成设备自身报警记录(status=1)
|
//执行报警处理:生成设备自身报警记录(status=1)
|
||||||
alarmLogService.doAlaramRecord("IEC61850", "yx", null, address, value);
|
alarmLogService.doAlaramRecord("IEC61850", "yx", null, analogData.getAddress(), analogData.getValue());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class LoginController {
|
|||||||
String password = SM4Utils.decrypt(user.getPassword(), privateKey);
|
String password = SM4Utils.decrypt(user.getPassword(), privateKey);
|
||||||
|
|
||||||
//用于开发测试,减少验证时间,正式使用应该改成true
|
//用于开发测试,减少验证时间,正式使用应该改成true
|
||||||
boolean hascode = false;
|
boolean hascode = true;
|
||||||
if (hascode) {
|
if (hascode) {
|
||||||
// 查询验证码
|
// 查询验证码
|
||||||
String code = webConfig.loginuserCache().get(user.getUuid());
|
String code = webConfig.loginuserCache().get(user.getUuid());
|
||||||
|
Loading…
Reference in New Issue
Block a user