Explorar el Código

增加投影灯模块

zhj hace 1 año
padre
commit
c995a1cf0e

+ 4 - 0
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -269,6 +269,10 @@ public enum InterfaceResultEnum {
     DEVICE_DISCONNECT("1102","请先断开其他设备","Please disconnect other devices first","Отключите сначала другое устройство"),
     DEVICE_TURN_ON("1103","请先开启输出状态","Please turn on the output state first","состояние на выходе"),
 
+    LACK_PROJECTION_LIGHT_ADDRESS("1200", "投影灯地址不能为空", "The projection lamp address cannot be empty" , "Адрес прожектора не может быть пустым"),
+    LACK_PROJECTION_LIGHT_NAME("1201", "投影灯的设备名称不能为空", "The device name of the projection lamp cannot be empty" , "Название устройства для проекции не может быть пустым"),
+    LACK_PROJECTION_LIGHT_SERIAL_PORT("1202", "请填写投影灯连接的云盒的串口号", "Enter the serial port number of the cloud box to which the projection light is connected", "Пожалуйста, заполните последовательный номер коробки с облаками, соединенной прожекторами"),
+    IMAGE_NUMBER_ERROR("1203", "当前设备仅支持切换四张图案片", "The current device supports only four pattern switches", "Нынешнее оборудование поддерживает только четыре схемы переключения"),
     ;
     private String code;
     private String msgCn;

+ 4 - 4
src/main/java/com/welampiot/common/YamlPropertySourceFactory.java

@@ -1,9 +1,5 @@
 package com.welampiot.common;
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Properties;
-
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
 import org.springframework.core.env.PropertiesPropertySource;
 import org.springframework.core.env.PropertySource;
@@ -11,6 +7,10 @@ import org.springframework.core.io.support.EncodedResource;
 import org.springframework.core.io.support.PropertySourceFactory;
 import org.springframework.lang.Nullable;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
 public class YamlPropertySourceFactory implements PropertySourceFactory {
 
     @Override

+ 37 - 0
src/main/java/com/welampiot/controller/BaseController.java

@@ -0,0 +1,37 @@
+package com.welampiot.controller;
+
+import com.welampiot.dto.UserDTO;
+import com.welampiot.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+public class BaseController {
+
+    @Autowired
+    private UserService userService;
+
+    protected List<Integer> getSectionList(String username) {
+        List<Integer> sectionList = new ArrayList<>();
+        UserDTO userDTO = userService.findUserByUserName(username);
+        if (userDTO == null) {
+            sectionList.add(0);
+            return sectionList;
+        }
+        if (userDTO.getRole() != 1) {
+            String[] split = userDTO.getZoneList().split(",");
+            if (split.length == 0) {
+                sectionList.add(0);
+            } else {
+                for (String s : split) {
+                    sectionList.add(Integer.valueOf(s));
+                }
+            }
+        }
+
+        return sectionList;
+    }
+}

+ 125 - 0
src/main/java/com/welampiot/controller/ProjectionLightController.java

@@ -0,0 +1,125 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.InterfaceResultEnum;
+import com.welampiot.dto.ProjectionLightDTO;
+import com.welampiot.service.ProjectionLightService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.ProjectionLightVO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@CrossOrigin
+@RequestMapping("/projectionLight")
+public class ProjectionLightController extends BaseController {
+    @Autowired
+    private ProjectionLightService projectionLightService;
+
+    @Autowired
+    private ToolUtils toolUtils;
+
+    /**
+     * 获取投影灯列表
+     * @param projectionLightVO projectionLightVO
+     * @return 投影灯列表
+     */
+    @PostMapping("/getList")
+    public BaseResult<?> getList(ProjectionLightVO projectionLightVO) {
+        Integer version = projectionLightVO.getVersion();
+        String username = projectionLightVO.getUsername();
+        if (username == null || username.trim().isEmpty()) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        Integer page = projectionLightVO.getPage();
+        Integer count = projectionLightVO.getCount();
+        if (page == null || page < 1) page = 1;
+        if (count == null || count <= 0) count = 16;
+        projectionLightVO.setPage(count * (page - 1));
+        projectionLightVO.setCount(count);
+        List<Integer> sectionList = getSectionList(username);
+        projectionLightVO.setSectionList(sectionList);
+        List<ProjectionLightDTO> projectionLightList = projectionLightService.getProjectionLightList(projectionLightVO);
+        ProjectionLightVO projectionLightVO1 = new ProjectionLightVO();
+        projectionLightVO1.setList(projectionLightList);
+        projectionLightVO1.setTotal(projectionLightList.size());
+        projectionLightVO1.setOnlineCount(projectionLightService.getOnlineProjectionLightCount(sectionList));
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, projectionLightVO1);
+    }
+
+    /**
+     * 获取当前图片
+     * @param id 投影灯id
+     */
+    @PostMapping("/currentImage")
+    public BaseResult<?> currentImage(Integer id, Integer version) {
+        if (id == null || id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        ProjectionLightDTO projectionLightDTO = projectionLightService.getProjectionLightDetailsById(id);
+        if (projectionLightDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+        ProjectionLightVO projectionLightVO = new ProjectionLightVO();
+        BeanUtils.copyProperties(projectionLightDTO, projectionLightVO);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version, projectionLightVO);
+    }
+
+    /**
+     * 投影灯切换显示图片
+     * @param id 投影灯id
+     */
+    @PostMapping("/chargeImage")
+    public BaseResult<?> chargeImage(Integer id, Integer version, Integer imageNumber) {
+        if (id == null || id == 0 || imageNumber == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR, version);
+        ProjectionLightDTO projectionLightDTO = projectionLightService.getProjectionLightDetailsById(id);
+        if (projectionLightDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL, version);
+
+        String sendTopic;
+        String resTopic;
+        if (projectionLightDTO.getWifiModel() == 3 || projectionLightDTO.getWifiModel() == 6) {
+            sendTopic = "/WEGW3/TransIn/";
+            resTopic = "/WEGW3/TransOut/";
+        } else if (projectionLightDTO.getWifiModel() == 1 || projectionLightDTO.getWifiModel() == 5) {
+            sendTopic = "/WEGW2/TransIn/";
+            resTopic = "/WEGW2/TransOut/";
+        } else {
+            sendTopic = "/WEGW/TransIn/";
+            resTopic = "/WEGW/TransOut/";
+        }
+        sendTopic += projectionLightDTO.getWifiNum();
+        resTopic += projectionLightDTO.getWifiNum();
+
+        // 发送的指令内容:投影灯选择图案片
+        String cmd;
+        if (imageNumber == 1) {
+            cmd = "E0070001010101EBEE";
+        } else if (imageNumber == 2) {
+            cmd = "E0070001010102ECEE";
+        } else if (imageNumber == 3) {
+            cmd = "E0070001010103EDEE";
+        } else if (imageNumber == 4) {
+            cmd = "E0070001010104EEEE";
+        } else {
+            return toolUtils.response(InterfaceResultEnum.IMAGE_NUMBER_ERROR, version);
+        }
+
+        projectionLightDTO.setSerialNum(projectionLightDTO.getSerialPort());
+        String cmdInfo;
+        if (projectionLightDTO.getWifiModel() == 3 || projectionLightDTO.getWifiModel() == 6) { // 云盒G300
+            cmdInfo = ToolUtils.getRandomString() + projectionLightDTO.getSerialNum() + cmd;
+        } else {
+            cmdInfo = ToolUtils.getRandomString() + cmd;
+        }
+
+        String backResult = toolUtils.sendMqttCmd(sendTopic, toolUtils.hexString2Bytes(cmdInfo), resTopic);
+        if (backResult != null && !backResult.trim().isEmpty()) {
+            projectionLightDTO.setUpdateTime(ToolUtils.getNowTime());
+            projectionLightDTO.setImageNumber(imageNumber);
+            projectionLightService.updateImageNumber(projectionLightDTO);
+        } else {
+            return toolUtils.response(InterfaceResultEnum.COMMAND_FAIL, version);
+        }
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS, version);
+    }
+}

+ 17 - 0
src/main/java/com/welampiot/dao/ProjectionLightDao.java

@@ -0,0 +1,17 @@
+package com.welampiot.dao;
+
+
+import com.welampiot.dto.ProjectionLightDTO;
+import com.welampiot.vo.ProjectionLightVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ProjectionLightDao {
+    List<ProjectionLightDTO> getProjectionLightList(ProjectionLightVO projectionLightVO);
+    Integer getOnlineProjectionLightCount(@Param("sectionList") List<Integer> sectionList);
+    ProjectionLightDTO getProjectionLightDetailsById(@Param("id") Integer id);
+    void addProjectionLight(ProjectionLightDTO projectionLightDTO);
+    void updateProjectionLight(ProjectionLightDTO projectionLightDTO);
+    void updateImageNumber(ProjectionLightDTO projectionLightDTO);
+}

+ 1 - 0
src/main/java/com/welampiot/dto/LampPoleDTO.java

@@ -136,4 +136,5 @@ public class LampPoleDTO {
     private String content;
     private String modelType;
     private String alarmTypeStr;
+    private Integer wifiModel; // 绑定的云盒型号
 }

+ 73 - 0
src/main/java/com/welampiot/dto/ProjectionLightDTO.java

@@ -0,0 +1,73 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class ProjectionLightDTO {
+    private Integer id;
+
+    /** 设备名称 */
+    private String name;
+
+    /** 灯杆id */
+    private Integer lampPoleId;
+
+    /** 创建时间 */
+    private String createTime;
+
+    /** 设备地址 */
+    private String address;
+
+    /** 当前显示图片的序号 */
+    private Integer imageNumber;
+
+    /** 灯杆名称 */
+    private String lampPoleName;
+
+    private Integer online;
+
+    private String updateTime;
+    private Integer serialPort;
+    private String installDate;
+    private String expirationDate;
+    /** 云盒型号 */
+    private Integer wifiModel;
+    private String wifiNum;
+    private String serialNum;
+
+    public void setSerialNum(Integer serialPort) {
+        if (serialPort == 2) {
+            this.serialNum = "02";
+        } else if (serialPort == 1) {
+            this.serialNum = "01";
+        } else {
+            this.serialNum = "00";
+        }
+    }
+
+    public static List<ProjectionLightDTO> getProjectionLightListByMap(List<Map<String, String>> projectionLightMap) {
+        List<ProjectionLightDTO> projectionLightList = new ArrayList<>();
+
+        for (Map<String, String> map : projectionLightMap) {
+            ProjectionLightDTO projectionLightDTO = new ProjectionLightDTO();
+            if (map.get("id") != null) {
+                projectionLightDTO.setId(Integer.parseInt(map.get("id")));
+            } else {
+                projectionLightDTO.setId(null);
+            }
+            if (map.get("serialPort") != null) {
+                projectionLightDTO.setSerialPort(Integer.parseInt(map.get("serialPort")));
+            }
+            projectionLightDTO.setName(map.get("name"));
+            projectionLightDTO.setAddress(map.get("address"));
+            projectionLightDTO.setInstallDate(map.get("installDate"));
+            projectionLightDTO.setExpirationDate(map.get("expirationDate"));
+            projectionLightList.add(projectionLightDTO);
+        }
+        return projectionLightList;
+    }
+}

+ 0 - 10
src/main/java/com/welampiot/security/CustomizeFilterInvocationSecurityMetadataSource.java

@@ -1,23 +1,13 @@
 package com.welampiot.security;
 
-import com.welampiot.common.BusinessException;
-import com.welampiot.common.ResultEnum;
-import com.welampiot.dto.PathDTO;
-import com.welampiot.dto.UserDTO;
 import com.welampiot.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.ConfigAttribute;
-import org.springframework.security.access.SecurityConfig;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.web.FilterInvocation;
 import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
 import org.springframework.stereotype.Component;
 import org.springframework.util.AntPathMatcher;
-import org.springframework.util.CollectionUtils;
 
 import java.util.Collection;
-import java.util.List;
 
 /**
  * 安全元数据源

+ 15 - 0
src/main/java/com/welampiot/service/ProjectionLightService.java

@@ -0,0 +1,15 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.ProjectionLightDTO;
+import com.welampiot.vo.ProjectionLightVO;
+
+import java.util.List;
+
+public interface ProjectionLightService {
+    List<ProjectionLightDTO> getProjectionLightList(ProjectionLightVO projectionLightVO);
+    Integer getOnlineProjectionLightCount(List<Integer> sectionList);
+    ProjectionLightDTO getProjectionLightDetailsById(Integer id);
+    void addProjectionLight(ProjectionLightDTO projectionLightDTO);
+    void updateProjectionLight(ProjectionLightDTO projectionLightDTO);
+    void updateImageNumber(ProjectionLightDTO projectionLightDTO);
+}

+ 52 - 0
src/main/java/com/welampiot/service/impl/LampPoleServiceImpl.java

@@ -51,6 +51,8 @@ public class LampPoleServiceImpl implements LampPoleService {
     private VideoMonitorService videoMonitorService;
     @Autowired
     private VideoGbInfoService videoGbInfoService;
+    @Autowired
+    private ProjectionLightService projectionLightService;
     @Override
     public List<LampPoleDTO> lampPoleList(LampPoleVO lampPoleVO) {
         List<LampPoleDTO> lampPoleDTOS = lampPoleDao.lampPoleList(lampPoleVO);
@@ -255,6 +257,32 @@ public class LampPoleServiceImpl implements LampPoleService {
                 System.out.println(devList);
             }
         }
+
+        // 添加投影灯
+        List<Map<String, String>> projectionLightMap = lampPoleVO.getProjectionLightList();
+        if (projectionLightMap != null && !projectionLightMap.isEmpty()) {
+            List<ProjectionLightDTO> projectionLightList = ProjectionLightDTO.getProjectionLightListByMap(projectionLightMap);
+            for (ProjectionLightDTO projectionLightDTO : projectionLightList) {
+                if (projectionLightDTO.getId() != null && projectionLightDTO.getId() != 0) continue;
+                if (projectionLightDTO.getAddress() == null || projectionLightDTO.getAddress().trim().isEmpty()) {
+                    return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_ADDRESS, lampPoleVO.getVersion());
+                }
+                if (projectionLightDTO.getName() == null || projectionLightDTO.getName().trim().isEmpty()) {
+                    return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_NAME, lampPoleVO.getVersion());
+                }
+                LampPoleDTO details = getNewLampPoleDetailsById(id);
+                if (details.getWifiModel() == 3 || details.getWifiModel() == 6) {
+                    if (projectionLightDTO.getSerialPort() == null) return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_SERIAL_PORT, lampPoleVO.getVersion());
+                }
+                projectionLightDTO.setLampPoleId(id);
+                projectionLightDTO.setName(projectionLightDTO.getName().trim());
+                projectionLightDTO.setAddress(projectionLightDTO.getAddress().trim());
+                projectionLightDTO.setCreateTime(ToolUtils.getNowTime());
+                projectionLightService.addProjectionLight(projectionLightDTO);
+            }
+        }
+
+
         LampPoleDTO lampPoleDTO1 = new LampPoleDTO();
         lampPoleDTO1.setId(lampPoleDTO.getId());
         lampPoleDTO1.setDevType(StringUtils.join(devType,","));
@@ -354,6 +382,30 @@ public class LampPoleServiceImpl implements LampPoleService {
 
             if (!add.getCode().equals("0000")) return add;
         }
+
+        // 编辑投影灯
+        List<Map<String, String>> projectionLightMap = lampPoleVO.getProjectionLightList();
+        if (projectionLightMap != null && !projectionLightMap.isEmpty()) {
+            List<ProjectionLightDTO> projectionLightList = ProjectionLightDTO.getProjectionLightListByMap(projectionLightMap);
+            for (ProjectionLightDTO p : projectionLightList) {
+                if (p.getId() == null || p.getId() == 0) continue;
+                if (p.getAddress() == null || p.getAddress().trim().isEmpty()) {
+                    return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_ADDRESS,lampPoleVO.getVersion());
+                }
+                if (p.getName() == null || p.getName().trim().isEmpty()) {
+                    return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_NAME,lampPoleVO.getVersion());
+                }
+                LampPoleDTO details = getNewLampPoleDetailsById(lampPoleVO.getId());
+                if (details.getWifiModel() == 3 || details.getWifiModel() == 6) {
+                    if (p.getSerialPort() == null) return toolUtils.response(InterfaceResultEnum.LACK_PROJECTION_LIGHT_SERIAL_PORT, lampPoleVO.getVersion());
+                }
+                p.setName(p.getName().trim());
+                p.setAddress(p.getAddress().trim());
+                p.setUpdateTime(ToolUtils.getNowTime());
+                projectionLightService.updateProjectionLight(p);
+            }
+        }
+
         return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampPoleVO.getVersion());
     }
 

+ 47 - 0
src/main/java/com/welampiot/service/impl/ProjectionLightServiceImpl.java

@@ -0,0 +1,47 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.ProjectionLightDao;
+import com.welampiot.dto.ProjectionLightDTO;
+import com.welampiot.service.ProjectionLightService;
+import com.welampiot.vo.ProjectionLightVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ProjectionLightServiceImpl implements ProjectionLightService {
+
+    @Autowired
+    private ProjectionLightDao projectionLightDao;
+
+    @Override
+    public List<ProjectionLightDTO> getProjectionLightList(ProjectionLightVO projectionLightVO) {
+        return projectionLightDao.getProjectionLightList(projectionLightVO);
+    }
+
+    @Override
+    public Integer getOnlineProjectionLightCount(List<Integer> sectionList) {
+        return projectionLightDao.getOnlineProjectionLightCount(sectionList);
+    }
+
+    @Override
+    public ProjectionLightDTO getProjectionLightDetailsById(Integer id) {
+        return projectionLightDao.getProjectionLightDetailsById(id);
+    }
+
+    @Override
+    public void addProjectionLight(ProjectionLightDTO projectionLightDTO) {
+        projectionLightDao.addProjectionLight(projectionLightDTO);
+    }
+
+    @Override
+    public void updateProjectionLight(ProjectionLightDTO projectionLightDTO) {
+        projectionLightDao.updateProjectionLight(projectionLightDTO);
+    }
+
+    @Override
+    public void updateImageNumber(ProjectionLightDTO projectionLightDTO) {
+        projectionLightDao.updateImageNumber(projectionLightDTO);
+    }
+}

+ 28 - 0
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -2132,4 +2132,32 @@ System.out.println(res);
         }
         return address;
     }
+
+    /**
+     * 获取当前时间
+     * @return 当前时间
+     */
+    public static String getNowTime() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(new Date());
+    }
+
+    public static int getSeq() {
+        Random random = new Random();
+        int min = 1;
+        int max = 65535;
+        return random.nextInt(max - min + 1) + min;
+    }
+
+    /**
+     * 获取2个字节16进制随机数
+     * @return 2个字节16进制随机数
+     */
+    public static String getRandomString() {
+        StringBuilder seqBuilder = new StringBuilder(Integer.toHexString(getSeq()));
+        while (seqBuilder.length() < 4) {
+            seqBuilder.insert(0, "0");
+        }
+        return seqBuilder.toString();
+    }
 }

+ 1 - 0
src/main/java/com/welampiot/vo/LampPoleVO.java

@@ -48,4 +48,5 @@ public class LampPoleVO implements Serializable {
     private Integer type; // 灯杆绑定的设备类型
     private Integer lampId; // 灯控id
     private List<LampPoleDTO> lampPoleDevList;
+    private List<Map<String, String>> projectionLightList; // 投影灯列表
 }

+ 48 - 0
src/main/java/com/welampiot/vo/ProjectionLightVO.java

@@ -0,0 +1,48 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.ProjectionLightDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ProjectionLightVO {
+    private Integer sectionId;
+    private Integer areaId;
+    private Integer online;
+    private Integer page;
+    private Integer count;
+    private String keyword;
+    private Integer version;
+    private String username;
+    private List<Integer> sectionList;
+
+    private Integer total;
+    private Integer onlineCount;
+    private List<ProjectionLightDTO> list;
+
+    private Integer id;
+
+    /** 设备名称 */
+    private String name;
+
+    /** 灯杆id */
+    private Integer lampPoleId;
+
+    /** 创建时间 */
+    private String createTime;
+
+    /** 设备地址 */
+    private String address;
+
+    /** 当前显示图片的序号 */
+    private Integer imageNumber;
+
+    /** 灯杆名称 */
+    private String lampPoleName;
+
+    private String updateTime;
+    private Integer serialPort;
+    private String installDate;
+    private String expirationDate;
+}

+ 1 - 1
src/main/resources/mapper/LampPoleMapper.xml

@@ -1301,7 +1301,7 @@
         select lp.id,c.online as chargeOnline,c.status as chargeStatus,c.equipmentElectricity,c.bill_amt as billAmt,
                s.id as screenId,s.status as screenStatus,s.light,s.volume,s.maxLight,s.playingid as playingId,
                p.name as programName,vm.image,vm.id as videoId,vm.address as videoAddress,b.id as broadcastId,b.itemId as programId,
-               bi.name as broadcastPro,w.day_flow as dayFlow,lp.latitude,lp.longitude
+               bi.name as broadcastPro,w.day_flow as dayFlow,lp.latitude,lp.longitude,w.model as wifiModel
         from lamp_pole lp
         left join wifi w on lp.id = w.lamp_pole_id
         left join charge c on lp.id = c.lamp_pole_id

+ 129 - 0
src/main/resources/mapper/ProjectionLightMapper.xml

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.welampiot.dao.ProjectionLightDao">
+    
+    <select id="getProjectionLightList" resultType="com.welampiot.dto.ProjectionLightDTO">
+        select p.id,p.lamp_pole_id as lampPoleId,p.address,p.createtime as createTime,p.image_number as imageNumber,
+               lp.name as lampPoleName,p.name,p.online,p.updatetime as updateTime,p.serial_port as serialPort,
+               p.install_date as installDate,p.expiration_date as expirationDate
+        from projection_light p
+        left join lamp_pole lp on p.lamp_pole_id = lp.id
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" separator="," item="item" open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="keyword != null and keyword != ''">
+            and p.name like '%${keyword}%'
+        </if>
+        <if test="areaId != null and areaId != 0">
+            and lp.areaid = #{areaId}
+        </if>
+        <if test="sectionId != null and sectionId != 0">
+            and lp.sectionid = #{sectionId}
+        </if>
+        <choose>
+            <when test="online == 2">
+                and p.online = 0
+            </when>
+            <when test="online == 1">
+                and p.online = 1
+            </when>
+        </choose>
+        <if test="page >= 0 and count > 0">
+            limit #{page},#{count}
+        </if>
+    </select>
+
+    <select id="getOnlineProjectionLightCount" resultType="java.lang.Integer">
+        select count(*)
+        from projection_light p
+        left join lamp_pole lp on p.lamp_pole_id = lp.id
+        where p.online = 1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" separator="," item="item" open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="getProjectionLightDetailsById" resultType="com.welampiot.dto.ProjectionLightDTO">
+        select p.id,p.lamp_pole_id as lampPoleId,p.address,p.createtime as createTime,p.image_number as imageNumber,
+               lp.name as lampPoleName,p.name,p.online,p.updatetime as updateTime,p.serial_port as serialPort,
+               p.install_date as installDate,p.expiration_date as expirationDate,w.model as wifiModel,w.num as wifiNum
+        from projection_light p
+        left join lamp_pole lp on p.lamp_pole_id = lp.id
+        left join wifi w on lp.id = w.lamp_pole_id
+        where p.id = #{id}
+    </select>
+
+    <insert id="addProjectionLight" parameterType="com.welampiot.dto.ProjectionLightDTO">
+        insert into
+        projection_light(
+        lamp_pole_id,
+        address,
+        `name`,
+        createtime
+        <if test="serialPort != null">
+            ,serial_port
+        </if>
+        <if test="installDate != null and installDate != ''">
+            ,install_date
+        </if>
+        <if test="expirationDate != null and expirationDate != ''">
+            ,expiration_date
+        </if>
+        )
+        values(
+        #{lampPoleId},
+        #{address},
+        #{name},
+        #{createTime}
+        <if test="serialPort != null">
+            ,#{serialPort}
+        </if>
+        <if test="installDate != null and installDate != ''">
+            ,#{installDate}
+        </if>
+        <if test="expirationDate != null and expirationDate != ''">
+            ,#{expirationDate}
+        </if>
+        )
+    </insert>
+
+    <update id="updateProjectionLight" parameterType="com.welampiot.dto.ProjectionLightDTO">
+        update
+            projection_light
+        set
+            address = #{address},
+            `name` = #{name}
+            <if test="serialPort != null">
+                ,serial_port = #{serialPort}
+            </if>
+            <if test="installDate != null and installDate != ''">
+                ,install_date = #{installDate}
+            </if>
+            <if test="expirationDate != null and expirationDate != ''">
+                ,expiration_date = #{expirationDate}
+            </if>
+            <if test="updateTime != null and updateTime != ''">
+                ,updatetime = #{updateTime}
+            </if>
+        where
+            id = #{id}
+    </update>
+
+    <update id="updateImageNumber" parameterType="com.welampiot.dto.ProjectionLightDTO">
+        update
+            projection_light
+        set
+            image_number = #{imageNumber},
+            updatetime = #{updateTime}
+        where
+            id = #{id}
+    </update>
+
+</mapper>

+ 1 - 1
src/main/resources/prod/application.yml

@@ -39,7 +39,7 @@ spring:
 
 welampiot:
   mqtt:
-    url: tcp://139.196.213.241:1883
+    url: tcp://129.28.166.25:1883
     clientId: welampiot_mqtt_client
     topics: /#
     username: admin

+ 1 - 1
src/main/resources/test/application.yml

@@ -39,7 +39,7 @@ spring:
 
 welampiot:
   mqtt:
-    url: tcp://139.196.213.241:1883
+    url: tcp://129.28.166.25:1883
     clientId: welampiot_mqtt_client
     topics: /#
     username: admin