This commit is contained in:
2023-03-27 10:57:27 +08:00
parent 1856307c79
commit 5f0b3c40e9
22 changed files with 611 additions and 35 deletions

View File

@@ -12,6 +12,7 @@ import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -171,7 +172,6 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
}
public boolean exe_error() {
if (this.error == 0) {
return true;
@@ -219,7 +219,7 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)){
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
@@ -273,7 +273,7 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
jo.put("task", task);
jo.put("walk_y", walk_y);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("mdhj_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
return jo;

View File

@@ -14,6 +14,7 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
@@ -216,7 +217,7 @@ public class HongXiangStationDeviceDriver extends AbstractOpcDeviceDriver implem
jo.put("mode", "联机");
jo.put("action", action);
jo.put("isOnline", true);
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("hxdj_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("task", this.getTask());
return jo;

View File

@@ -18,6 +18,7 @@ import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -321,7 +322,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
jo.put("temperature", temperature);
jo.put("finish", finish);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("hx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("countdown_house", countdown_house);
jo.put("countdown_min", countdown_min);

View File

@@ -21,6 +21,7 @@ import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspect
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -401,17 +402,17 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver();
// hongXiangConveyorDeviceDriver.writing("to_close_door", "1");
if(!StrUtil.startWith(taskDto.getTask_code(), "-")){
if(ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))){
if (!StrUtil.startWith(taskDto.getTask_code(), "-")) {
if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) {
String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString();
Device lampDevice = deviceAppService.findDeviceByCode(lamp);
if(ObjectUtil.isEmpty(lampDevice)){
if (ObjectUtil.isEmpty(lampDevice)) {
return;
}
if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver();
logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯"+ lamp +"报警信号");
lampThreecolorDeviceDriver.writing("to_command","1");
logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯" + lamp + "报警信号");
lampThreecolorDeviceDriver.writing("to_command", "1");
}
}
}
@@ -452,7 +453,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage()+ ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol) );
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
}
@@ -480,7 +481,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
//行架机械手申请任务
if (mode == 2 && move == 0 && task == 0 && !requireSucess) {
boolean res = applyTask();
if (res){
if (res) {
notCreateInstMessage = "";
notCreateTaskMessage = "";
feedMessage = "";
@@ -513,7 +514,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
last_walk_y = walk_y;
last_error = error;
last_task = task;
last_heartbeat = heartbeat;
last_heartbeat = heartbeat;
}
@@ -562,21 +563,21 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver();
if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:"+instruction.getInstruction_code();
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:"+instruction.getInstruction_code();
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:"+instruction.getInstruction_code();
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
@@ -584,14 +585,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "有货,无法下发指令!指令号:"+instruction.getInstruction_code();
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevice_code() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:"+instruction.getInstruction_code();
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
@@ -620,11 +621,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing("to_command", "1");
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_open_door","1");
hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_open_door","1");
hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
}
this.setNow_steps_type(2);
this.setRequireSucess(true);
@@ -954,7 +955,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
jo.put("task", task);
jo.put("walk_y", walk_y);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("notCreateTaskMessage", notCreateTaskMessage);

View File

@@ -26,6 +26,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -469,7 +470,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("is_click", true);

View File

@@ -22,6 +22,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -429,7 +430,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("is_click", true);

View File

@@ -21,6 +21,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -445,7 +446,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
jo.put("carrier_direction", carrier_direction);
jo.put("task", task);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("is_click", true);

View File

@@ -22,6 +22,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -304,7 +305,7 @@ public class SiemensOneFloorAGVConveyorDeviceDriver extends AbstractOpcDeviceDri
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("is_click", true);

View File

@@ -18,6 +18,7 @@ import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDevic
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -1418,7 +1419,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
jo.put("action_1", action1);
jo.put("action_2", action2);
jo.put("walk_y", walk_y);
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("fqhj_error_type", String.valueOf(this.getError())));
jo.put("task1", this.getTask1());
jo.put("task2", this.getTask2());
jo.put("isOnline", this.getIsonline());

View File

@@ -21,6 +21,7 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -943,7 +944,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
jo.put("action", action);
jo.put("is_click", true);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError())));
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("inst_message", this.inst_message);

View File

@@ -0,0 +1,63 @@
package org.nl.acs.history;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.nl.modules.system.domain.Dict;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.DictService;
import org.nl.modules.system.service.dto.DictDetailDto;
import org.nl.modules.system.service.impl.DictDetailServiceImpl;
import org.nl.modules.system.service.impl.DictServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
/**
* @author: geng by
* @createDate: 2023/3/15
*/
public class ErrorUtil {
public static ConcurrentHashMap<String, List<DictDetailDto>> dictMap = new ConcurrentHashMap<>();
public static String getDictDetail(String type, String error_code) {
getDict();
List<DictDetailDto> dictDetailDtos = dictMap.get(type);
String detail = null;
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
for (int i = 0; i < dictDetailDtos.size(); i++) {
DictDetailDto dictDetailDto = dictDetailDtos.get(i);
String value = dictDetailDto.getValue();
String label = dictDetailDto.getLabel();
if (StrUtil.equals(value, error_code)) {
detail = label;
break;
}
}
}
return detail == null ? "字典表未配置对应的报警信息" : detail;
}
public static void getDict() {
if (ObjectUtil.isEmpty(dictMap)) {
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailServiceImpl.class);
DictService dictService = SpringContextHolder.getBean(DictServiceImpl.class);
List<Dict> dictDtos = dictService.queryAll();
for (int i = 0; i < dictDtos.size(); i++) {
Dict dictDto = dictDtos.get(i);
dictMap.put(dictDto.getName(), getDict(dictDto.getName(), t -> {
return dictDetailService.getDictByName(t);
}));
}
}
}
public static List<DictDetailDto> getDict(String name, Function<String, List<DictDetailDto>> f) {
return f.apply(name);
}
}

View File

@@ -0,0 +1,77 @@
package org.nl.acs.history.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.modules.logging.annotation.Log;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
/**
* @author gengby
* @date 2023-03-15
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "设备报警记录管理")
@RequestMapping("/api/deviceErrorLog")
@Slf4j
public class DeviceErrorLogController {
private final DeviceErrorLogService acsDeviceErrorLogService;
@GetMapping
@Log("查询设备报警记录")
@ApiOperation("查询设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(acsDeviceErrorLogService.queryAll(whereJson,page),HttpStatus.OK);
}
@PostMapping
@Log("新增设备报警记录")
@ApiOperation("新增设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:add')")
public ResponseEntity<Object> create(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.create(dto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改设备报警记录")
@ApiOperation("修改设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.update(dto);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除设备报警记录")
@ApiOperation("删除设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
acsDeviceErrorLogService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出设备报警记录")
@ApiOperation("导出设备报警记录")
@GetMapping(value = "/download")
//@PreAuthorize("@el.check('acsDeviceErrorLog:list')")
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
acsDeviceErrorLogService.download(acsDeviceErrorLogService.queryAll(whereJson), response);
}
}

View File

@@ -0,0 +1,74 @@
package org.nl.acs.history.service;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @description 服务接口
* @author gengby
* @date 2023-03-15
**/
public interface DeviceErrorLogService {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<AcsDeviceErrorLogDto>
*/
List<DeviceErrorLogDto> queryAll(Map whereJson);
/**
* 根据ID查询
* @param error_log_uuid ID
* @return AcsDeviceErrorLog
*/
DeviceErrorLogDto findById(String error_log_uuid);
/**
* 根据编码查询
* @param code code
* @return AcsDeviceErrorLog
*/
DeviceErrorLogDto findByCode(String code);
/**
* 创建
* @param dto /
*/
void create(DeviceErrorLogDto dto);
/**
* 编辑
* @param dto /
*/
void update(DeviceErrorLogDto dto);
/**
* 多选删除
* @param ids /
*/
void deleteAll(String[] ids);
/**
* 导出数据
* @param dtos 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<DeviceErrorLogDto> dtos, HttpServletResponse response) throws IOException;
}

View File

@@ -0,0 +1,29 @@
package org.nl.acs.history.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description /
* @author gengby
* @date 2023-03-15
**/
@Data
public class DeviceErrorLogDto implements Serializable {
/** 报警日志标识 */
private String error_log_uuid;
/** 设备编码 */
private String device_code;
/** 报警编码 */
private String error_code;
/** 报警信息 */
private String error_info;
/** 报警时间 */
private String error_time;
}

View File

@@ -0,0 +1,137 @@
package org.nl.acs.history.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.core.bean.ResultBean;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author gengby
* @description 服务实现
* @date 2023-03-15
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class DeviceErrorLogServiceImpl implements DeviceErrorLogService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String device_code = MapUtil.getStr(whereJson, "device_code");
String error_code = MapUtil.getStr(whereJson, "error_code");
String error_info = MapUtil.getStr(whereJson, "error_info");
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
String where = "1 = 1 ";
if (StrUtil.isNotEmpty(device_code)) {
where += "and device_code like '%" + device_code + "%'";
}
if (StrUtil.isNotEmpty(error_code)) {
where += "and error_code like '%" + error_code + "%'";
}
if (StrUtil.isNotEmpty(error_info)) {
where += "and error_info like '%" + error_info + "%'";
}
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), where, "error_time desc");
final JSONObject json = rb.pageResult();
return json;
}
@Override
public List<DeviceErrorLogDto> queryAll(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONArray arr = wo.query().getResultJSONArray(0);
List<DeviceErrorLogDto> list = arr.toJavaList(DeviceErrorLogDto.class);
return list;
}
@Override
public DeviceErrorLogDto findById(String error_log_uuid) {
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = wo.query("error_log_uuid ='" + error_log_uuid + "'").uniqueResult(0);
final DeviceErrorLogDto obj = (DeviceErrorLogDto) JSONObject.toJavaObject(json, DeviceErrorLogDto.class);
return obj;
}
@Override
public DeviceErrorLogDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
final DeviceErrorLogDto obj = (DeviceErrorLogDto) JSONObject.toJavaObject(json, DeviceErrorLogDto.class);
return obj;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DeviceErrorLogDto dto) {
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
dto.setError_log_uuid(IdUtil.simpleUUID());
dto.setDevice_code(dto.getDevice_code());
dto.setError_code(dto.getError_code());
dto.setError_info(dto.getError_info());
dto.setError_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(DeviceErrorLogDto dto) {
DeviceErrorLogDto entity = this.findById(dto.getError_log_uuid());
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.update(json);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(String[] ids) {
WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
for (String error_log_uuid : ids) {
wo.delete("error_log_uuid = '" + error_log_uuid + "'");
}
}
@Override
public void download(List<DeviceErrorLogDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (DeviceErrorLogDto acsDeviceErrorLog : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("设备编码", acsDeviceErrorLog.getDevice_code());
map.put("报警编码", acsDeviceErrorLog.getError_code());
map.put("报警信息", acsDeviceErrorLog.getError_info());
map.put("报警时间", acsDeviceErrorLog.getError_time());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -47,6 +47,8 @@ public interface DictService {
*/
List<DictDto> queryAll(DictQueryCriteria dict);
List<Dict> queryAll();
/**
* 创建
* @param resources /

View File

@@ -16,6 +16,7 @@
package org.nl.modules.system.service.impl;
import lombok.RequiredArgsConstructor;
import org.nl.acs.history.ErrorUtil;
import org.nl.modules.common.utils.PageUtil;
import org.nl.modules.common.utils.QueryHelp;
import org.nl.modules.common.utils.RedisUtils;
@@ -39,9 +40,9 @@ import java.util.List;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
* @author Zheng Jie
* @date 2019-04-10
*/
@Service
@RequiredArgsConstructor
@CacheConfig(cacheNames = "dict")
@@ -53,8 +54,8 @@ public class DictDetailServiceImpl implements DictDetailService {
private final RedisUtils redisUtils;
@Override
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
}
@@ -64,17 +65,21 @@ public class DictDetailServiceImpl implements DictDetailService {
dictDetailRepository.save(resources);
// 清理缓存
delCaches(resources);
Dict dict = dictRepository.findById(resources.getDict().getId()).get();
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(DictDetail resources) {
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
ValidationUtil.isNull(dictDetail.getId(), "DictDetail", "id", resources.getId());
resources.setId(dictDetail.getId());
dictDetailRepository.save(resources);
// 清理缓存
delCaches(resources);
Dict dict = dictRepository.findById(resources.getDict().getId()).get();
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
}
@Override
@@ -90,9 +95,11 @@ public class DictDetailServiceImpl implements DictDetailService {
// 清理缓存
delCaches(dictDetail);
dictDetailRepository.deleteById(id);
Dict dict = dictRepository.findById(id).get();
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
}
public void delCaches(DictDetail dictDetail){
public void delCaches(DictDetail dictDetail) {
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
redisUtils.del("dict::name:" + dict.getName());
}

View File

@@ -60,6 +60,12 @@ public class DictServiceImpl implements DictService {
return dictMapper.toDto(list);
}
@Override
public List<Dict> queryAll() {
List<Dict> list = dictRepository.findAll();
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Dict resources) {