| ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| ximon-admin/src/main/java/com/sandu/ximon/admin/dto/ErrorMsgDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,31 @@ package com.sandu.ximon.admin.controller; import com.sandu.common.domain.ResponseVO; import com.sandu.common.object.BaseConditionVO; import com.sandu.common.security.annotation.AnonymousAccess; import com.sandu.common.util.ResponseUtil; import com.sandu.ximon.admin.service.ErrorMsgService; import com.sandu.ximon.admin.utils.RedisUtils; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @author LiuHaoNan * @date 2022/7/27 */ @RestController @AllArgsConstructor @RequestMapping("/v1/errorMsg") public class ErrorMsgController { private final ErrorMsgService errorMsgService; @AnonymousAccess @GetMapping("/listMsg") public ResponseVO<Object> list(BaseConditionVO conditionVO){ return ResponseUtil.success(errorMsgService.listMsg(conditionVO)); } } ximon-admin/src/main/java/com/sandu/ximon/admin/dto/ErrorMsgDto.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,41 @@ package com.sandu.ximon.admin.dto; import lombok.Data; import java.time.LocalDateTime; /** * @author LiuHaoNan * @date 2022/7/27 * æ éå表 */ @Data public class ErrorMsgDto { /** * 设å¤ç */ private String Mac; /** * æ éç */ private Integer ErrorCode; /** * æ éæè¿° */ private String ErrorDesc; /** * æ éæ¶é´ */ private LocalDateTime ErrorTime; /** * 设å¤ç±»å 0ï¼åç¯ 1ï¼å çµæ¡© 2ï¼å¤§æ° */ private Integer DeviceType; private String DeviceJson; } ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,60 @@ package com.sandu.ximon.admin.service; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.sandu.common.object.BaseConditionVO; import com.sandu.ximon.admin.dto.ErrorMsgDto; import com.sandu.ximon.dao.bo.LightReportErrorBo; import com.sandu.ximon.dao.domain.Light; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author LiuHaoNan * @date 2022/7/25 * 设å¤éè¯¯ä¿¡æ¯ */ @Service @AllArgsConstructor public class ErrorMsgService { private final LightReportErrorService lightReportErrorService; private final C3mReportErrorService c3mReportErrorService; private final LightService lightService; public List<ErrorMsgDto> listMsg(BaseConditionVO baseConditionVO) { List<ErrorMsgDto> errorMsgDtos = new ArrayList<>(); //åç¯æ éæ°æ® List<LightReportErrorBo> lightReportErrors = lightReportErrorService.queryErrorCode(baseConditionVO); if (!lightReportErrors.isEmpty()) { for (LightReportErrorBo lightReportError : lightReportErrors) { ErrorMsgDto errorMsgDto = new ErrorMsgDto(); errorMsgDto.setMac(lightReportError.getDeviceCode()); errorMsgDto.setErrorCode(lightReportError.getErrorCode()); errorMsgDto.setErrorDesc(lightReportError.getErrorMsg()); errorMsgDto.setErrorTime(lightReportError.getCreateTime()); errorMsgDto.setDeviceType(0); Light one = lightService.getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, lightReportError.getDeviceCode())); if (one != null) { errorMsgDto.setDeviceJson(JSON.toJSONString(one)); } errorMsgDtos.add(errorMsgDto); } } //å çµæ¡©æ éæ°æ® //对errorMsgDtosæå建æ¶é´åå errorMsgDtos.sort((a, b) -> b.getErrorTime().compareTo(a.getErrorTime())); //æå¨å页 baseConditionVO.getPageNo() å½å页 baseConditionVO.getPageSize() æ¯é¡µæ¡æ° return errorMsgDtos.subList((baseConditionVO.getPageNo() - 1) * baseConditionVO.getPageSize(), baseConditionVO.getPageNo() * baseConditionVO.getPageSize()); } } ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java
@@ -1,6 +1,7 @@ package com.sandu.ximon.admin.service; import com.github.pagehelper.PageHelper; import com.sandu.common.object.BaseConditionVO; import com.sandu.common.service.impl.BaseServiceImpl; import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightErrorCodeReportInnerFrame; import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightErrorEnum; @@ -49,4 +50,28 @@ } return lightReportErrorBos; } /** * æ¥è¯¢æ å¸¸æ°æ® * * @return */ public List<LightReportErrorBo> queryErrorCode(BaseConditionVO baseConditionVO) { PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); List<LightReportErrorBo> lightReportErrorBos = baseMapper.listError(SecurityUtils.getClientId()); for (LightReportErrorBo lightReportErrorBo : lightReportErrorBos) { Integer errorCode = lightReportErrorBo.getErrorCode(); StringBuilder sb = new StringBuilder(); LightErrorEnum[] values = LightErrorEnum.values(); for (LightErrorEnum value : values) { if ((value.getCode() & errorCode) > 0) { sb.append(value.getMessage()); } } lightReportErrorBo.setErrorMsg(sb.toString()); } return lightReportErrorBos; } }