fix: history

This commit is contained in:
yanps
2023-12-07 10:54:24 +08:00
parent e2aca6f6f6
commit 92fdf0ccd6
3 changed files with 35 additions and 13 deletions

View File

@@ -50,8 +50,8 @@ public class ErrorUtil {
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
List<Dict> dtos = dictDetailDtos
.stream()
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("0"))
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("-1"))
.filter(dictDetailDto -> !"0".equals(dictDetailDto.getValue()))
.filter(dictDetailDto -> !"-1".equals(dictDetailDto.getValue()))
.collect(Collectors.toList());
dtos.forEach(dictDetailDto -> map.put(Integer.parseInt(dictDetailDto.getValue()), dictDetailDto.getLabel()));
}
@@ -62,7 +62,6 @@ public class ErrorUtil {
public static void getDict() {
if (ObjectUtil.isEmpty(dictMap)) {
ISysDictService dictDetailService = SpringContextHolder.getBean(SysDictServiceImpl.class);
//DictService dictService = SpringContextHolder.getBean(DictServiceImpl.class);
List<Dict> dictDtos = dictDetailService.queryAll();
for (int i = 0; i < dictDtos.size(); i++) {
Dict dictDto = dictDtos.get(i);
@@ -123,7 +122,7 @@ public class ErrorUtil {
}
}
Map<String, String> map = new HashMap<>();
Map<String, String> map = new HashMap<>(2);
map.put("code", replace(code));
map.put("info", replace(message));
return map;

View File

@@ -32,6 +32,12 @@ public class DeviceErrorLogController {
private final DeviceErrorLogService acsDeviceErrorLogService;
/**
*
* @param whereJson
* @param page
* @return
*/
@GetMapping
@Log("查询设备报警记录")
@ApiOperation("查询设备报警记录")
@@ -40,6 +46,11 @@ public class DeviceErrorLogController {
return new ResponseEntity<>(acsDeviceErrorLogService.queryAll(whereJson,page),HttpStatus.OK);
}
/**
*
* @param dto
* @return
*/
@PostMapping
@Log("新增设备报警记录")
@ApiOperation("新增设备报警记录")
@@ -49,6 +60,11 @@ public class DeviceErrorLogController {
return new ResponseEntity<>(HttpStatus.CREATED);
}
/**
*
* @param dto
* @return
*/
@PutMapping
@Log("修改设备报警记录")
@ApiOperation("修改设备报警记录")
@@ -58,6 +74,11 @@ public class DeviceErrorLogController {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
/**
*
* @param ids
* @return
*/
@Log("删除设备报警记录")
@ApiOperation("删除设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:del')")
@@ -67,6 +88,12 @@ public class DeviceErrorLogController {
return new ResponseEntity<>(HttpStatus.OK);
}
/**
*
* @param response
* @param whereJson
* @throws IOException
*/
@Log("导出设备报警记录")
@ApiOperation("导出设备报警记录")
@GetMapping(value = "/download")

View File

@@ -48,6 +48,8 @@ public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorL
@Autowired
private AcsDeviceErrorLogMapper acsDeviceErrorLogMapper;
private static final String ERROR_DELETE = "被删除或无权限,操作失败!";
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page1) {
LambdaQueryWrapper<AcsDeviceErrorLog> wrapper = getAcsDeviceErrorLogLambdaQueryWrapper(whereJson);
@@ -55,7 +57,7 @@ public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorL
IPage<AcsDeviceErrorLog> acsDeviceErrorLogIPage = acsDeviceErrorLogMapper.selectPage(objectIPage, wrapper);
List<AcsDeviceErrorLog> records = acsDeviceErrorLogIPage.getRecords();
long total = acsDeviceErrorLogIPage.getTotal();
HashMap<String, Object> json = new HashMap<>();
HashMap<String, Object> json = new HashMap<>(2);
json.put("content", records);
json.put("totalElements", total);
return json;
@@ -89,18 +91,12 @@ public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorL
@Override
public DeviceErrorLogDto findById(String error_log_uuid) {
AcsDeviceErrorLog one = getOne(Wrappers.lambdaQuery(AcsDeviceErrorLog.class).eq(AcsDeviceErrorLog::getError_log_uuid, 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 BeanUtil.copyProperties(one, DeviceErrorLogDto.class);
}
@Override
public DeviceErrorLogDto findByCode(String code) {
AcsDeviceErrorLog one = getOne(Wrappers.lambdaQuery(AcsDeviceErrorLog.class).eq(AcsDeviceErrorLog::getDevice_code, 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 BeanUtil.copyProperties(one, DeviceErrorLogDto.class);
}
@@ -122,7 +118,7 @@ public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorL
@Transactional(rollbackFor = Exception.class)
public void update(DeviceErrorLogDto dto) {
DeviceErrorLogDto entity = this.findById(dto.getError_log_uuid());
if (entity == null) {throw new BadRequestException("被删除或无权限,操作失败!");}
if (entity == null) {throw new BadRequestException(ERROR_DELETE);}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
updateById(BeanUtil.copyProperties(dto, AcsDeviceErrorLog.class));
@@ -131,7 +127,7 @@ public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorL
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(String[] ids) {
if (ids == null || ids.length == 0) {throw new BadRequestException("被删除或无权限,操作失败!");}
if (ids == null || ids.length == 0) {throw new BadRequestException(ERROR_DELETE);}
for (String id : ids) {
this.removeById(id);
}