Browse Source

管控记录

develop
王兴琳 3 months ago
parent
commit
de6625b488
  1. 32
      zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java
  2. 37
      zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java

32
zc-business/src/main/java/com/zc/business/controller/DcOperLogController.java

@ -55,35 +55,9 @@ public class DcOperLogController extends BaseController {
// @PreAuthorize("@ss.hasPermi('iot:facility:list')")
@GetMapping("list")
public TableDataInfo listFacility(DcOperLog dcOperLog, @RequestParam(value = "endTime", required = false) Date endTime, @RequestParam(value = "startTime", required = false) Date startTime) {
List<DcOperLog> dcOperLogs = dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime);
ArrayList<DcOperLog> operLogArrayList = new ArrayList<>();
if (dcOperLogs==null||dcOperLogs.size()==0){
return getDataTable(dcOperLogs);
}
String content="";
for (DcOperLog log:dcOperLogs){
String dcDeviceType = log.getDcDeviceType();
if ("5".equals(dcDeviceType)){
content="语音广播";
}else if ("2".equals(dcDeviceType)){
content="情报板";
}
String jsonResult = log.getJsonResult();
if (("[]".equals(jsonResult)|| StringUtils.isBlank(jsonResult))&&("5".equals(dcDeviceType)||"2".equals(dcDeviceType))){
String jsonResults = String.format(
"[{\"deviceType\":%s,\"deviceName\":%s,\"result\":{\"code\":500,\"content\":\"{%s数据异常\"}}]",
log.getDcDeviceType(), log.getDcDeviceName(), content
);
JSONArray objects = new JSONArray(jsonResults);
log.setJsonResult(objects.toString());
log.setRemark(content+"数据异常");
String devices = String.format("[{\"devices\":[{\"deviceType\":%s}]}]", log.getDcDeviceType());
JSONArray devicesJson = new JSONArray(devices);
log.setOperParam(devicesJson.toString());
}
operLogArrayList.add(log);
}
return getDataTable(operLogArrayList);
// List<DcOperLog> dcOperLogs = dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime);
return getDataTable(dcOperLogService.pageDcOperLog(dcOperLog, endTime, startTime));
}
/**

37
zc-business/src/main/java/com/zc/business/service/impl/DcOperLogServiceImpl.java

@ -1,9 +1,11 @@
package com.zc.business.service.impl;
import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.domain.DcOperLog;
import com.zc.business.enums.DeviceTypeEnum;
import com.zc.business.enums.UniversalEnum;
@ -11,10 +13,7 @@ import com.zc.business.mapper.DcOperLogMapper;
import com.zc.business.service.IDcOperLogService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 调用功能记录Service业务层处理
@ -43,8 +42,36 @@ public class DcOperLogServiceImpl extends ServiceImpl<DcOperLogMapper, DcOperLog
@Override
public List<DcOperLog> pageDcOperLog(DcOperLog dcOperLog, Date endTime, Date startTime) {
PageUtils.startPage();
return list(getDcOperLogLambdaQueryWrapper(dcOperLog, endTime, startTime));
List<DcOperLog> dcOperLogs = list(getDcOperLogLambdaQueryWrapper(dcOperLog, endTime, startTime));
if (dcOperLogs==null||dcOperLogs.size()==0){
return dcOperLogs ;
}
String content="";
for (DcOperLog log:dcOperLogs){
String dcDeviceType = log.getDcDeviceType();
if ("5".equals(dcDeviceType)){
content="语音广播";
}else if ("2".equals(dcDeviceType)){
content="情报板";
}
String jsonResult = log.getJsonResult();
if (("[]".equals(jsonResult)|| StringUtils.isBlank(jsonResult))&&("5".equals(dcDeviceType)||"2".equals(dcDeviceType))){
String jsonResults = String.format(
"[{\"deviceType\":%s,\"deviceName\":%s,\"result\":{\"code\":500,\"content\":\"{%s数据异常\"}}]",
log.getDcDeviceType(), log.getDcDeviceName(), content
);
JSONArray objects = new JSONArray(jsonResults);
log.setJsonResult(objects.toString());
log.setRemark(content+"数据异常");
String devices = String.format("[{\"devices\":[{\"deviceType\":%s}]}]", log.getDcDeviceType());
JSONArray devicesJson = new JSONArray(devices);
log.setOperParam(devicesJson.toString());
}
}
return dcOperLogs ;
}
@Override

Loading…
Cancel
Save