| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.ximon.admin.dto.ErrorMsgDto; |
| | | import com.sandu.ximon.admin.utils.ListPagingUtils; |
| | | import com.sandu.ximon.dao.bo.C3ReportErrorBo; |
| | | import com.sandu.ximon.dao.bo.LightReportErrorBo; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.Light; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | private final C3ChargingService c3ChargingService; |
| | | |
| | | |
| | | public CommonPage listMsg(BaseConditionVO baseConditionVO, String type) { |
| | | if (StringUtils.isEmpty(type)) { |
| | | throw new BusinessException("设备故障类型不能为空!"); |
| | | } |
| | | CommonPage commonPage = null; |
| | | switch (type) { |
| | | case "单灯故障": |
| | | //单灯故障数据 |
| | | commonPage = lightReportErrorService.queryErrorCode(baseConditionVO); |
| | | if (!commonPage.getList().isEmpty()) { |
| | | for (LightReportErrorBo lightReportError : (List<LightReportErrorBo>) commonPage.getList()) { |
| | | ErrorMsgDto errorMsgDto = new ErrorMsgDto(); |
| | | errorMsgDto.setMac(lightReportError.getDeviceCode()); |
| | | errorMsgDto.setErrorCode(lightReportError.getErrorCode()); |
| | | errorMsgDto.setErrorDesc(lightReportError.getErrorMsg()); |
| | | errorMsgDto.setErrorTime(lightReportError.getCreateTime()); |
| | | errorMsgDto.setDeviceType(1); |
| | | Light one = lightService.getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, lightReportError.getDeviceCode())); |
| | | if (one != null) { |
| | | errorMsgDto.setDeviceJson(JSON.toJSONString(one)); |
| | | } |
| | | } |
| | | /** |
| | | * 单灯 |
| | | * |
| | | * @param baseConditionVO |
| | | * @return |
| | | */ |
| | | public CommonPage lightListMsg(BaseConditionVO baseConditionVO) { |
| | | List<ErrorMsgDto> errorMsgDtoList = new ArrayList<>(); |
| | | //单灯故障数据 |
| | | CommonPage commonPage = lightReportErrorService.queryErrorCode(baseConditionVO); |
| | | if (!commonPage.getList().isEmpty()) { |
| | | for (LightReportErrorBo lightReportError : (List<LightReportErrorBo>) commonPage.getList()) { |
| | | ErrorMsgDto errorMsgDto = new ErrorMsgDto(); |
| | | errorMsgDto.setMac(lightReportError.getDeviceCode()); |
| | | errorMsgDto.setErrorCode(lightReportError.getErrorCode()); |
| | | errorMsgDto.setErrorDesc(lightReportError.getErrorMsg()); |
| | | errorMsgDto.setErrorTime(lightReportError.getCreateTime()); |
| | | errorMsgDto.setDeviceType(1); |
| | | Light one = lightService.getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, lightReportError.getDeviceCode())); |
| | | System.out.println(lightReportError.getDeviceCode() + " ---code "); |
| | | if (one != null) { |
| | | errorMsgDto.setDeviceJson(JSON.toJSONString(one)); |
| | | } else { |
| | | errorMsgDto.setDeviceJson("系统未找到设备数据"); |
| | | } |
| | | break; |
| | | case "充电桩故障": |
| | | //充电桩故障数据 |
| | | List<C3ReportErrorBo> c3ReportErrorBos = c3mReportErrorService.listReportError(baseConditionVO); |
| | | if (!c3ReportErrorBos.isEmpty()) { |
| | | List<C3ReportErrorBo> list = c3ReportErrorBos; |
| | | list.forEach(c3ReportError -> { |
| | | ErrorMsgDto errorMsgDto = new ErrorMsgDto(); |
| | | errorMsgDto.setMac(c3ReportError.getC3Mac()); |
| | | errorMsgDto.setErrorDesc(c3ReportError.getErrorMsg()); |
| | | errorMsgDto.setErrorTime(c3ReportError.getCreateTime()); |
| | | errorMsgDto.setDeviceType(3); |
| | | C3mCharging one = c3ChargingService.getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3ReportError.getC3Mac())); |
| | | if (one != null) { |
| | | errorMsgDto.setDeviceJson(JSON.toJSONString(one)); |
| | | } |
| | | }); |
| | | commonPage = new CommonPage(); |
| | | commonPage.setList(c3ReportErrorBos); |
| | | } |
| | | |
| | | break; |
| | | case "大气故障": |
| | | //大气故障数据 todo 暂无 |
| | | |
| | | break; |
| | | default: |
| | | throw new BusinessException("类型不正确,请确认!"); |
| | | errorMsgDtoList.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()); |
| | | // ListPagingUtils.pages(errorMsgDtos, baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | commonPage.setList(errorMsgDtoList); |
| | | return commonPage; |
| | | } |
| | | |
| | | /** |
| | | * 充电桩 |
| | | * |
| | | * @param baseConditionVO |
| | | * @return |
| | | */ |
| | | public List<ErrorMsgDto> C3ListMsg(BaseConditionVO baseConditionVO) { |
| | | List<ErrorMsgDto> errorMsgDtoList = new ArrayList<>(); |
| | | //充电桩故障数据 |
| | | List<C3ReportErrorBo> c3ReportErrorBos = c3mReportErrorService.listReportError(baseConditionVO); |
| | | if (!c3ReportErrorBos.isEmpty()) { |
| | | List<C3ReportErrorBo> list = c3ReportErrorBos; |
| | | list.forEach(c3ReportError -> { |
| | | ErrorMsgDto errorMsgDto = new ErrorMsgDto(); |
| | | errorMsgDto.setMac(c3ReportError.getC3Mac()); |
| | | errorMsgDto.setErrorDesc(c3ReportError.getErrorMsg()); |
| | | errorMsgDto.setErrorTime(c3ReportError.getCreateTime()); |
| | | errorMsgDto.setDeviceType(3); |
| | | C3mCharging one = c3ChargingService.getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3ReportError.getC3Mac())); |
| | | if (one != null) { |
| | | errorMsgDto.setDeviceJson(JSON.toJSONString(one)); |
| | | }else { |
| | | errorMsgDto.setDeviceJson("系统未找到设备数据"); |
| | | } |
| | | errorMsgDtoList.add(errorMsgDto); |
| | | }); |
| | | } |
| | | return errorMsgDtoList; |
| | | } |
| | | |
| | | /** |
| | | * 大气 |
| | | * |
| | | * @param baseConditionVO |
| | | * @return |
| | | */ |
| | | public List<ErrorMsgDto> atmosphereListMsg(BaseConditionVO baseConditionVO) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | } |