opt: 异常日志,流量限制,创建任务优化

This commit is contained in:
yanps
2024-02-28 16:35:50 +08:00
parent c010166c28
commit ae3b25f35a
13 changed files with 154 additions and 96 deletions

View File

@@ -71,7 +71,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
@Autowired
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
@Autowired
private LimitRegionalService limitRegionalService=SpringContextHolder.getBean(LimitRegionalService.class);
private LimitRegionalService limitRegionalService = SpringContextHolder.getBean(LimitRegionalService.class);
@Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
@@ -177,51 +177,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
y_position = this.itemProtocol.getY_position();
iserror = this.itemProtocol.device_status;
if (to_onset != last_to_onset) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset" + last_to_onset + "->" + to_onset);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
if(mode != last_mode){
requireSucess = false;
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (walk_y != last_walk_y) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y));
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y" + last_walk_y + "->" + walk_y);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
if (x_position != last_x_position) {
logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position" + last_x_position + "->" + x_position);
}
if (y_position != last_y_position) {
logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position" + last_y_position + "->" + y_position);
}
update_instruction_status();
} catch (Exception var17) {
@@ -356,32 +316,32 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
if(startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!指令号:" + instruction.getInstruction_code();
"无货,无法下发指令或" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!" + "!指令号:" + instruction.getInstruction_code();
return false;
}
//判断经过的烘箱是否关门
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(start_device_code, next_device_code);
if(!hongxiangCloseDoor){
if (!hongxiangCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
return false;
}
}
if(nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!指令号:" + instruction.getInstruction_code();
"无货,无法下发指令或" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!" + "!指令号:" + instruction.getInstruction_code();
return false;
}
//判断经过的烘箱是否关门
boolean hongxiangCloseDoor = this.hongxiangCloseDoor( next_device_code, start_device_code);
if(!hongxiangCloseDoor){
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(next_device_code, start_device_code);
if (!hongxiangCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
return false;
}
@@ -435,9 +395,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
String msg = "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code());
+ ",指令终点:" + instruction.getNext_device_code();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(msg)
.build();
luceneExecuteLogService.deviceExecuteLog(logDto);
List list = new ArrayList<>();
Map map = new HashMap();
map.put("to_onset", start_addr);
@@ -482,32 +447,32 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
if(startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!任务号:" + task.getTask_code();
"无货,无法下发指令或" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!" + "!任务号:" + task.getTask_code();
return false;
}
//判断经过的烘箱是否关门
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(task.getStart_device_code(), task.getNext_device_code());
if(!hongxiangCloseDoor){
if (!hongxiangCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + task.getStart_device_code() + ",放货位:" + task.getNext_device_code() + ",存在关联的同一列烘箱设备未关门!任务号:" + task.getTask_code();
return false;
}
}
if(nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
if (ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!任务号:" + task.getTask_code();
"无货,无法下发指令或" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!" + "!任务号:" + task.getTask_code();
return false;
}
//判断经过的烘箱是否关门
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(task.getStart_device_code(), task.getNext_device_code());
if(!hongxiangCloseDoor){
if (!hongxiangCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + task.getStart_device_code() + ",放货位:" + task.getNext_device_code() + ",存在关联的同一列烘箱设备未关门!任务号:" + task.getTask_code();
return false;
}
@@ -616,6 +581,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
if(ObjectUtil.isEmpty(start_addr) || ObjectUtil.isEmpty(next_addr)){
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "或设备:" + nextDevice.getDevice_code() + "地址值!");
}
String msg = "当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
+ ",指令终点:" + instdto.getNext_device_code();
@@ -627,16 +595,16 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
List list = new ArrayList<>();
Map map = new HashMap();
map.put("code", "to_onset");
map.put("value",StrUtil.isNotBlank(start_addr)? start_addr : "0");
map.put("value", StrUtil.isNotBlank(start_addr) ? start_addr : "0");
Map map1 = new HashMap();
map1.put("code", "to_target");
map1.put("value",StrUtil.isNotBlank(next_addr)? next_addr : "0");
map1.put("value", StrUtil.isNotBlank(next_addr) ? next_addr : "0");
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value",instdto.getInstruction_code());
map2.put("value", instdto.getInstruction_code());
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value","1");
map3.put("value", "1");
list.add(map);
list.add(map1);
list.add(map2);
@@ -667,7 +635,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
/**
* 判断经过的烘箱是否关门
*/
private boolean hongxiangCloseDoor(String start_device_code,String next_device_code) {
private boolean hongxiangCloseDoor(String start_device_code, String next_device_code) {
boolean flag = true;
List<String> ovenDeviceCodeList = null;
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
@@ -682,14 +650,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
ovenDeviceCodeList = ovenInspectSiteDeviceDriver.getExtraDeviceCodes("link_device_code");
}
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
if(CollUtil.isNotEmpty(ovenDeviceCodeList)){
if (CollUtil.isNotEmpty(ovenDeviceCodeList)) {
for (String s : ovenDeviceCodeList) {
Device device = deviceAppService.findDeviceByCode(s);
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
//判断关联设备是否开门
if (hongXiangConveyorDeviceDriver.getDoor() == 1) {
notCreateInstMessage = "关联设备->" + device + "烘箱门未关闭!";
notCreateInstMessage = "关联设备->" + device + "烘箱门未关闭!";
flag = false;
break;
}
@@ -701,6 +669,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
/**
* 判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门
*
* @param start_device_code
* @param next_device_code
* @return
@@ -1087,7 +1056,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
} else if (this.getAction() == 4) {
action = "放货完成";
}
if(error == 0 && iserror){
if (error == 0 && iserror) {
this.setMessage(LangProcess.msg("universal_message4"));
}
jo.put("device_name", this.getDevice().getDevice_name());
@@ -1195,4 +1164,51 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
return null;
}
/*if (to_onset != last_to_onset) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset" + last_to_onset + "->" + to_onset);
}
if (to_command != last_to_command) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command" + last_to_command + "->" + to_command);
}
if (to_target != last_to_target) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
if (mode != last_mode) {
requireSucess = false;
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action" + last_action + "->" + action);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (walk_y != last_walk_y) {
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y));
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y" + last_walk_y + "->" + walk_y);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
if (x_position != last_x_position) {
logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position" + last_x_position + "->" + x_position);
}
if (y_position != last_y_position) {
logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position));
logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position" + last_y_position + "->" + y_position);
}*/
}

View File

@@ -540,6 +540,9 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
}
if(this.itemProtocol.getIsError() && error == 0){
this.setMessage(LangProcess.msg("universal_message4"));
iserror = true;
}else if(error == 0) {
iserror = false;
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);

View File

@@ -159,6 +159,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
task = this.itemProtocol.getTask();
x_position = this.itemProtocol.getX_position();
y_position = this.itemProtocol.getY_position();
heartbeat = this.itemProtocol.getHeartbeat();
if (mode != last_mode) {
requireSucess = false;
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));

View File

@@ -40,7 +40,6 @@ public class DeviceErrorLogController {
*/
@GetMapping
@Log("查询设备报警记录")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(acsDeviceErrorLogService.queryAll(whereJson,page),HttpStatus.OK);
}
@@ -52,7 +51,6 @@ public class DeviceErrorLogController {
*/
@PostMapping
@Log("新增设备报警记录")
public ResponseEntity<Object> create(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.create(dto);
return new ResponseEntity<>(HttpStatus.CREATED);
@@ -65,7 +63,6 @@ public class DeviceErrorLogController {
*/
@PutMapping
@Log("修改设备报警记录")
public ResponseEntity<Object> update(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.update(dto);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
@@ -77,7 +74,6 @@ public class DeviceErrorLogController {
* @return
*/
@Log("删除设备报警记录")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
acsDeviceErrorLogService.deleteAll(ids);
@@ -91,7 +87,6 @@ public class DeviceErrorLogController {
* @throws IOException
*/
@Log("导出设备报警记录")
@GetMapping(value = "/download")
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
acsDeviceErrorLogService.download(acsDeviceErrorLogService.queryAll(whereJson), response);

View File

@@ -526,7 +526,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
if(regional(dto.getStart_device_code(), dto.getNext_device_code())){
throw new BadRequestException(LangProcess.msg("error_regional_max"));
}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
@@ -1731,6 +1733,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
int count = 0;
boolean startRegionalExit = true;
boolean nextRegionalExit = true;
if(StrUtil.isEmpty(startRegion) || StrUtil.isEmpty(nextRegion)){
return true;
}
//控制指令生成
LimitRegionalDto limitRegionalDtos = limitRegionalService.selectByReging(startRegion, nextRegion);
if (ObjectUtil.isNotEmpty(limitRegionalDtos)) {

View File

@@ -2,6 +2,7 @@ package org.nl.acs.limit_regional.server.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -21,7 +22,9 @@ import org.nl.acs.limit_regional.server.mapper.LimitRegionalMapper;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.utils.ConvertUtil;
import org.nl.acs.utils.PageUtil;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.language.LangProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -45,7 +48,7 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
@Autowired
private DeviceAppService deviceAppService;
private List<LimitRegional> dataList;
public List<LimitRegional> dataList;
@Override
@@ -82,7 +85,7 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
@Override
public void add(JSONObject json) {
LimitRegional limitRegional = new LimitRegional();
limitRegional.setId(String.valueOf(RandomUtil.randomInt(8)));
limitRegional.setId(RandomUtil.randomNumbers(8));
limitRegional.setStart_regional(json.getString("start_regional"));
limitRegional.setNext_regional(json.getString("next_regional"));
limitRegional.setStart_exclude_device(json.getString("startExcludeDevice"));
@@ -91,12 +94,14 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
String regex = "\\d+";
boolean isNumeric = max_num.matches(regex);
if(!isNumeric){
throw new RuntimeException("最大数请输入纯数字");
throw new BadRequestException("请输入纯数字");
}
limitRegional.setIs_active("1");
limitRegional.setMax_num(max_num);
limitRegional.setCreate_by("auto");
limitRegional.setCreate_time(DateUtil.now());
limitRegionalMapper.insert(limitRegional);
dataList.add(limitRegional);
}
@@ -106,13 +111,25 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
return;
}
for (String id : ids) {
LimitRegional limitRegional = limitRegionalMapper.selectById(id);
if(ObjectUtil.isNull(limitRegional)){
throw new BadRequestException("这个对象不存在");
}
limitRegionalMapper.deleteById(id);
}
dataList.removeIf(limitRegional -> CollUtil.contains(Arrays.asList(ids), limitRegional.getId()));
}
@Override
public void update(JSONObject json) {
if(StrUtil.isEmpty(json.getString("id"))){
throw new BadRequestException(LangProcess.msg("error_checkNull", "流量限制id"));
}
LimitRegional id = limitRegionalMapper.selectById(json.getString("id"));
if(ObjectUtil.isNull(id)){
throw new BadRequestException(LangProcess.msg("error_isNull", "流量限制id="+json.getString("id")));
}
LimitRegional limitRegional = new LimitRegional();
String currentUsername = SecurityUtils.getCurrentUsername();
limitRegional.setId(json.getString("id"));
@@ -124,19 +141,30 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
String regex = "\\d+";
boolean isNumeric = max_num.matches(regex);
if(!isNumeric){
throw new RuntimeException("最大数请输入纯数字");
throw new RuntimeException("请输入纯数字");
}
limitRegional.setMax_num(max_num);
limitRegional.setUpdate_by(currentUsername);
limitRegional.setUpdate_time(DateUtil.now());
limitRegionalMapper.updateById(limitRegional);
dataList.forEach(limitRegional1 -> {
if (limitRegional.getId().equals(limitRegional1.getId())) {
limitRegional1.setStart_regional(limitRegional.getStart_regional());
limitRegional1.setNext_regional(limitRegional.getNext_regional());
limitRegional1.setStart_exclude_device(limitRegional.getStart_exclude_device());
limitRegional1.setNext_exclude_device(limitRegional.getNext_exclude_device());
limitRegional1.setMax_num(limitRegional.getMax_num());
limitRegional1.setUpdate_by(limitRegional.getUpdate_by());
limitRegional1.setUpdate_time(limitRegional.getUpdate_time());
}
});
}
@Override
public void updateStatusById(Map whereJson) {
String id = whereJson.get("id").toString();
if(StrUtil.isEmpty(id)){
return;
throw new BadRequestException("id为空");
}
LimitRegional limitRegional = new LimitRegional();
limitRegional.setId(id);
@@ -144,6 +172,12 @@ public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMap
limitRegional.setUpdate_by(SecurityUtils.getCurrentUsername());
limitRegional.setUpdate_time(DateUtil.now());
limitRegionalMapper.updateById(limitRegional);
dataList.forEach(limitRegional1 -> {if (limitRegional.getId().equals(limitRegional1.getId())) {
limitRegional1.setIs_active(limitRegional.getIs_active());
limitRegional1.setUpdate_by(limitRegional.getUpdate_by());
limitRegional1.setUpdate_time(limitRegional.getUpdate_time());
}
});
}
@Override

View File

@@ -290,6 +290,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
}
private void runNew() {
Async20Access accessor = null;

View File

@@ -138,14 +138,14 @@ public class LogAspect {
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
/*@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
SysLog log = new SysLog("ERROR",System.currentTimeMillis() - currentTime.get());
currentTime.remove();
log.setException_detail(ThrowableUtil.getStackTrace(e).getBytes());
HttpServletRequest request = RequestHolder.getHttpServletRequest();
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log);
}
}*/
public String getUsername() {
try {

View File

@@ -30,15 +30,12 @@ public class SysLogController {
@Autowired
private ISysLogService logService;
@GetMapping
//@SaCheckPermission("@el.check()")
public ResponseEntity<Object> query(@RequestParam Map criteria, PageQuery pageable){
criteria.put("log_type","INFO");
return new ResponseEntity<>(TableDataInfo.build(logService.queryAll(criteria,pageable)), HttpStatus.OK);
}
@GetMapping(value = "/user")
//
public ResponseEntity<Object> queryUserLog(@RequestParam Map criteria, PageQuery pageable){
criteria.put("log_type","INFO");
criteria.put("username", SecurityUtils.getCurrentUsername());
@@ -46,7 +43,6 @@ public class SysLogController {
}
@GetMapping(value = "/error")
// @SaCheckPermission("@el.check()")
public ResponseEntity<Object> queryErrorLog(@RequestParam Map criteria, PageQuery pageable){
criteria.put("log_type","ERROR");
@@ -54,7 +50,6 @@ public class SysLogController {
}
@GetMapping(value = "/error/{id}")
// @SaCheckPermission("@el.check()")
public ResponseEntity<Object> queryErrorLogs(@PathVariable String id){
return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK);
@@ -62,7 +57,6 @@ public class SysLogController {
@DeleteMapping(value = "/del/error")
@Log("删除所有ERROR日志")
// @SaCheckPermission("@el.check()")
public ResponseEntity<Object> delAllErrorLog(){
logService.delAllByError();
@@ -71,7 +65,6 @@ public class SysLogController {
@DeleteMapping(value = "/del/info")
@Log("删除所有INFO日志")
// @SaCheckPermission("@el.check()")
public ResponseEntity<Object> delAllInfoLog(){
logService.delAllByInfo();