2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-06-06 dd01070290fa24b29588df6ed2a4740f8bab3dce
灯杆倾斜处理
已修改6个文件
124 ■■■■ 文件已修改
dao/src/main/java/com/sandu/ximon/dao/domain/LightPoleHeelingProcessing.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/LightPoleHeelingMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LightPoleHeelingMapper.xml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LightPoleHeelingProcessingMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightPoleHeelingProcessingParam.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingProcessingServices.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LightPoleHeelingProcessing.java
@@ -18,18 +18,13 @@
    /**
     * 处理号
     */
    @TableId
    @TableId(type = IdType.AUTO)
    private Long processingNumber;
    /**
     * 警告号
     */
    private Long warningNumber;
    /**
     * 处理后状态
     */
    private Integer processingState;
    /**
     * 处理意见
@@ -47,6 +42,11 @@
    private LocalDateTime createTime;
    /**
     * 处理后警告等级
     */
    private Integer warningLevel;
    /**
     * 处理后X轴
     */
    private Double theXAxis;
@@ -61,6 +61,26 @@
     */
    private Double theZAxis;
    /**
     * 处理前X轴
     */
    private Double theXAxisOld;
    /**
     * 处理前Y轴
     */
    private Double theYAxisOld;
    /**
     * 处理前Z轴
     */
    private Double theZAxisOld;
    /**
     * 处理前警告等级
     */
    private Integer warningLevelOld;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}
dao/src/main/java/com/sandu/ximon/dao/mapper/LightPoleHeelingMapper.java
@@ -9,6 +9,8 @@
@Mapper
public interface LightPoleHeelingMapper extends BaseMapper<LightPoleHeeling> {
    List<LightPoleHeeling> listLightPoleHeeling(String keyword, Integer processingState, Long userid);
    LightPoleHeeling lightPoleHeelingDetail(Long userId, Long warningNumber);
}
dao/src/main/resources/mapper/LightPoleHeelingMapper.xml
@@ -41,6 +41,23 @@
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            </if>
        </where>
    </select>
    <select id="lightPoleHeelingDetail" resultType="com.sandu.ximon.dao.domain.LightPoleHeeling">
        SELECT t1.*, t3.pole_code,
        t3.pole_name
        FROM light_pole_heeling t1
        LEFT JOIN pole_binding t2 ON t1.mac = t2.device_code
        AND t2.device_type = 8
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            <if test="warningNumber != null">
                AND t1.warning_number = #{warningNumber}
            </if>
            <if test="userId != null">
                AND (t3.user_id = #{userId} OR t3.client_id = #{userId})
            </if>
        </where>
    </select>
</mapper>
dao/src/main/resources/mapper/LightPoleHeelingProcessingMapper.xml
@@ -7,18 +7,24 @@
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightPoleHeelingProcessing">
            <id property="processingNumber" column="processing_number" jdbcType="BIGINT"/>
            <result property="warningNumber" column="warning_number" jdbcType="BIGINT"/>
            <result property="processingState" column="processing_state" jdbcType="INTEGER"/>
            <result property="processingOpinion" column="processing_opinion" jdbcType="VARCHAR"/>
            <result property="processingPerson" column="processing_person" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="warningLevel" column="warning_level" jdbcType="INTEGER"/>
            <result property="theXAxis" column="the_x_axis" jdbcType="DOUBLE"/>
            <result property="theYAxis" column="the_y_axis" jdbcType="DOUBLE"/>
            <result property="theZAxis" column="the_z_axis" jdbcType="DOUBLE"/>
            <result property="theXAxisOld" column="the_x_axis_old" jdbcType="DOUBLE"/>
            <result property="theYAxisOld" column="the_y_axis_old" jdbcType="DOUBLE"/>
            <result property="theZAxisOld" column="the_z_axis_old" jdbcType="DOUBLE"/>
            <result property="warningLevelOld" column="warning_level_old" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
        processing_number,warning_number,processing_state,
        processing_number,warning_number,
        processing_opinion,processing_person,create_time,
        the_x_axis,the_y_axis,the_z_axis
        warning_level,the_x_axis,the_y_axis,
        the_z_axis,the_x_axis_old,the_y_axis_old,
        the_z_axis_old,warning_level_old
    </sql>
</mapper>
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightPoleHeelingProcessingParam.java
@@ -1,7 +1,9 @@
package com.sandu.ximon.admin.param;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
 * 灯杆倾斜警告处理
@@ -12,19 +14,11 @@
@Data
public class LightPoleHeelingProcessingParam {
    @NotEmpty(message = "灯杆倾斜硬件地址不能为空")
    private String deviceName = "";
    /**
     * 警告号
     */
    @NotNull(message = "警告号不能为空!")
    private Long warningNumber;
    /**
     * 处理后状态
     */
    private Integer processingState;
    /**
     * 处理意见
@@ -34,22 +28,24 @@
    /**
     * 处理人
     */
    @NotEmpty(message = "处理人不能为空!")
    private String processingPerson;
    /**
     * 处理后X轴
     */
    @NotNull(message = "处理后X轴值不能为空!")
    private Double theXAxis;
    /**
     * 处理后Y轴
     */
    @NotNull(message = "处理后Y轴值不能为空!")
    private Double theYAxis;
    /**
     * 处理后Z轴
     */
    @NotNull(message = "处理后Z轴值不能为空!")
    private Double theZAxis;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingProcessingServices.java
@@ -1,9 +1,15 @@
package com.sandu.ximon.admin.service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.param.LightPoleHeelingProcessingParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.domain.LightPoleHeeling;
import com.sandu.ximon.dao.domain.LightPoleHeelingProcessing;
import com.sandu.ximon.dao.mapper.LightPoleHeelingMapper;
import com.sandu.ximon.dao.mapper.LightPoleHeelingProcessingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -20,12 +26,45 @@
     * 灯杆倾斜警告处理
     */
    public boolean ProcessingLightPoleHeeling(LightPoleHeelingProcessingParam param) {
        LightPoleHeelingService lightPoleHeelingService = SpringContextHolder.getBean(LightPoleHeelingService.class);
        LightPoleHeeling one = SpringContextHolder.getBean(LightPoleHeelingMapper.class).
                lightPoleHeelingDetail(SecurityUtils.getClientId(), param.getWarningNumber());
        if (one == null) {
            throw new BusinessException("处理的灯杆倾斜数据不存在!");
        }
        LightPoleHeelingProcessing lightPoleHeelingProcessing = new LightPoleHeelingProcessing();
        lightPoleHeelingProcessing.setWarningNumber(param.getWarningNumber());
        lightPoleHeelingProcessing.setProcessingOpinion(param.getProcessingOpinion());
        lightPoleHeelingProcessing.setProcessingPerson(param.getProcessingPerson());
        lightPoleHeelingProcessing.setProcessingState(param.getProcessingState());
        lightPoleHeelingProcessing.setTheXAxis(param.getTheXAxis());
        lightPoleHeelingProcessing.setTheYAxis(param.getTheYAxis());
        lightPoleHeelingProcessing.setTheZAxis(param.getTheZAxis());
        return save(lightPoleHeelingProcessing);
        lightPoleHeelingProcessing.setTheXAxisOld(one.getTheXAxis());
        lightPoleHeelingProcessing.setTheYAxisOld(one.getTheYAxis());
        lightPoleHeelingProcessing.setTheZAxisOld(one.getTheZAxis());
        lightPoleHeelingProcessing.setWarningLevelOld(one.getWarningLevel());
        //警告等级
        if (Math.abs(param.getTheXAxis()) >= 10 || Math.abs(param.getTheYAxis()) >= 10) {
            //一级警告
            lightPoleHeelingProcessing.setWarningLevel(1);
        } else if ((Math.abs(param.getTheXAxis()) >= 5 && Math.abs(param.getTheXAxis()) < 10)
                || (Math.abs(param.getTheYAxis()) >= 5 && Math.abs(param.getTheYAxis()) < 10)) {
            //二级警告
            lightPoleHeelingProcessing.setWarningLevel(2);
        } else {
            //正常
            lightPoleHeelingProcessing.setWarningLevel(0);
        }
        boolean save = save(lightPoleHeelingProcessing);
        if (save) {
            //设置为已处理
            one.setProcessingState(1);
            lightPoleHeelingService.updateById(one);
        }
        return save;
    }
}