package com.sandu.ximon.admin.service; import com.github.pagehelper.PageHelper; 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; import com.sandu.ximon.dao.bo.LightReportErrorBo; import com.sandu.ximon.dao.domain.LightReportError; import com.sandu.ximon.dao.mapper.LightReportErrorMapper; import org.springframework.stereotype.Service; import java.util.List; /** * @author chenjiantian * @date 2021/12/17 17:47 */ @Service public class LightReportErrorService extends BaseServiceImpl { public void saveReportError(String deviceName, A5LightErrorCodeReportInnerFrame codeRespInnerFrame) { LightReportError lightReportError = new LightReportError(); lightReportError.setDeviceCode(deviceName); lightReportError.setErrorCode(codeRespInnerFrame.getErrorCode()); save(lightReportError); } public List listReportError(int pageNo, int pageSize, String keyword) { PageHelper.startPage(pageNo,pageSize); List lightReportErrorBos = baseMapper.listReportError(keyword); 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; } }