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