2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-09-28 0a86cfc623812431f41bc0255e9e6e7730e60df0
fix
已修改5个文件
151 ■■■■■ 文件已修改
dao/src/main/resources/mapper/LightReportErrorMapper.xml 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mReportErrorService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LightReportErrorMapper.xml
@@ -5,12 +5,12 @@
<mapper namespace="com.sandu.ximon.dao.mapper.LightReportErrorMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportError">
            <id property="lightReportErrorId" column="light_report_error_id" jdbcType="BIGINT"/>
            <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
            <result property="lightAddress" column="light_address" jdbcType="VARCHAR"/>
            <result property="errorCode" column="error_code" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <id property="lightReportErrorId" column="light_report_error_id" jdbcType="BIGINT"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="lightAddress" column="light_address" jdbcType="VARCHAR"/>
        <result property="errorCode" column="error_code" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <resultMap id="listReportError" type="com.sandu.ximon.dao.bo.LightReportErrorBo" extends="BaseResultMap">
        <result property="poleName" column="pole_name" jdbcType="INTEGER"/>
@@ -27,6 +27,7 @@
        AND t2.device_type = 0
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            t1.error_code != 0
            <if test="keyword != null and keyword != ''">
                AND (
                t3.id LIKE CONCAT('%', #{keyword},'%')
@@ -46,16 +47,17 @@
    <select id="listError" resultType="com.sandu.ximon.dao.bo.LightReportErrorBo"
            parameterType="java.lang.Long">
        SELECT
            t1.*
        t1.*
        FROM
            light_report_error t1
                LEFT JOIN pole t3 ON t1.device_code = t3.device_code
        light_report_error t1
        LEFT JOIN pole t3 ON t1.device_code = t3.device_code
        WHERE
            <if test="userid != null">
                t3.client_id = #{userId} OR t3.user_id = #{userId}
                </if>
            t1.light_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( light_report_error.light_report_error_id ) AS max_id FROM light_report_error GROUP BY light_report_error.device_code ) AS t )
        <if test="userid != null">
            t3.client_id = #{userId} OR t3.user_id = #{userId}
        </if>
        t1.light_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( light_report_error.light_report_error_id ) AS
        max_id FROM light_report_error GROUP BY light_report_error.device_code ) AS t )
        ORDER BY
            t1.create_time DESC
        t1.create_time DESC
    </select>
</mapper>
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java
@@ -9,6 +9,7 @@
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -24,8 +25,8 @@
    @AnonymousAccess
    @GetMapping("/listMsg")
    public ResponseVO<Object> list(BaseConditionVO conditionVO){
    public ResponseVO<Object> list(BaseConditionVO conditionVO, @RequestParam(value = "type", required = false) String type) {
      return ResponseUtil.success(errorMsgService.listMsg(conditionVO));
        return ResponseUtil.success(errorMsgService.listMsg(conditionVO, type));
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mReportErrorService.java
@@ -1,6 +1,7 @@
package com.sandu.ximon.admin.service;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3ErrorCodeReportInnerFrame;
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java
@@ -2,13 +2,17 @@
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;
@@ -30,49 +34,66 @@
    private final C3ChargingService c3ChargingService;
    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(1);
                Light one = lightService.getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, lightReportError.getDeviceCode()));
                if (one != null) {
                    errorMsgDto.setDeviceJson(JSON.toJSONString(one));
                }
                errorMsgDtos.add(errorMsgDto);
            }
    public CommonPage listMsg(BaseConditionVO baseConditionVO, String type) {
        if (StringUtils.isEmpty(type)) {
            throw new BusinessException("设备故障类型不能为空!");
        }
        //充电桩故障数据
        List<C3ReportErrorBo> c3ReportErrorBos = c3mReportErrorService.listReportError(baseConditionVO);
        if (!c3ReportErrorBos.isEmpty()) {
            c3ReportErrorBos.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 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));
                        }
                    }
                }
                errorMsgDtos.add(errorMsgDto);
            });
                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("类型不正确,请确认!");
        }
        //大气故障数据  todo 暂无
        //对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());
//
//
//        //对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());
        return commonPage;
    }
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.domain.CommonPage;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
@@ -15,6 +16,7 @@
import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightErrorEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.ListPagingUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.dao.bo.LightReportErrorBo;
import com.sandu.ximon.dao.domain.LightReportError;
@@ -23,6 +25,7 @@
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @author chenjiantian
@@ -69,11 +72,12 @@
     *
     * @return
     */
    public List<LightReportErrorBo> queryErrorCode(BaseConditionVO baseConditionVO) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
    public CommonPage queryErrorCode(BaseConditionVO baseConditionVO) {
        List<LightReportErrorBo> lightReportErrorBos = baseMapper.listError(SecurityUtils.getClientId());
        for (LightReportErrorBo lightReportErrorBo : lightReportErrorBos) {
        lightReportErrorBos = lightReportErrorBos.stream().filter(bean -> bean.getErrorCode() != 0).collect(Collectors.toList());
        CommonPage commonPage = ListPagingUtils.pages(lightReportErrorBos, baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        for (LightReportErrorBo lightReportErrorBo : (List<LightReportErrorBo>) commonPage.getList()) {
            Integer errorCode = lightReportErrorBo.getErrorCode();
            StringBuilder sb = new StringBuilder();
            LightErrorEnum[] values = LightErrorEnum.values();
@@ -84,7 +88,7 @@
            }
            lightReportErrorBo.setErrorMsg(sb.toString());
        }
        return lightReportErrorBos;
        return commonPage;
    }
    /**