Browse Source

获取空开设备详情

zhj 2 years ago
parent
commit
0e5a64058d

+ 13 - 0
src/main/java/com/welampiot/controller/ElectricBoxController.java

@@ -6,6 +6,7 @@ import com.welampiot.dto.ElectricBoxDTO;
 import com.welampiot.service.AirSwitchInfoService;
 import com.welampiot.service.ElectricBoxService;
 import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.AirSwitchDetailVO;
 import com.welampiot.vo.AirSwitchInfoReturnVO;
 import com.welampiot.vo.ElectricBoxReturnVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,4 +81,16 @@ public class ElectricBoxController {
         }
         return BaseResult.success(airSwitchInfoReturnVO);
     }
+
+    /**
+     * 获取空开设备详情
+     * @param request
+     * @return
+     */
+    @PostMapping("/airSwitchDetail")
+    public BaseResult<AirSwitchInfoDTO> airSwitchDetail(HttpServletRequest request){
+        Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
+        AirSwitchDetailVO airSwitchDetail = airSwitchInfoService.getAirSwitchDetail(id);
+        return BaseResult.success(airSwitchDetail);
+    }
 }

+ 2 - 0
src/main/java/com/welampiot/dao/AirSwitchInfoDao.java

@@ -26,4 +26,6 @@ public interface AirSwitchInfoDao {
     Integer getPolicyIdByBoxId(@Param("boxId") Integer boxId);
 
     String getPolicyNameByPolicyId(@Param("policyId") Integer policyId);
+
+    AirSwitchInfoDTO getAirSwitchDetailById(@Param("id") Integer id);
 }

+ 3 - 0
src/main/java/com/welampiot/service/AirSwitchInfoService.java

@@ -1,5 +1,6 @@
 package com.welampiot.service;
 
+import com.welampiot.vo.AirSwitchDetailVO;
 import com.welampiot.vo.AirSwitchInfoReturnVO;
 
 
@@ -14,4 +15,6 @@ import com.welampiot.vo.AirSwitchInfoReturnVO;
  */
 public interface AirSwitchInfoService {
     AirSwitchInfoReturnVO getAirSwitchInfo(Integer boxId, Integer online);
+
+    AirSwitchDetailVO getAirSwitchDetail(Integer id);
 }

+ 18 - 0
src/main/java/com/welampiot/service/impl/AirSwitchInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.welampiot.service.impl;
 import com.welampiot.dao.AirSwitchInfoDao;
 import com.welampiot.dto.AirSwitchInfoDTO;
 import com.welampiot.service.AirSwitchInfoService;
+import com.welampiot.vo.AirSwitchDetailVO;
 import com.welampiot.vo.AirSwitchInfoReturnVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -78,4 +79,21 @@ public class AirSwitchInfoServiceImpl implements AirSwitchInfoService {
         airSwitchInfoReturnVO.setList(airSwitchInfoDTOS);
         return airSwitchInfoReturnVO;
     }
+
+    @Override
+    public AirSwitchDetailVO getAirSwitchDetail(Integer id) {
+        AirSwitchDetailVO airSwitchDetailVO = new AirSwitchDetailVO();
+        AirSwitchInfoDTO airSwitchInfoDTO = airSwitchInfoDao.getAirSwitchDetailById(id);
+            airSwitchDetailVO.setName(airSwitchInfoDTO.getName());
+            airSwitchDetailVO.setAddress(airSwitchInfoDTO.getAddress());
+            airSwitchDetailVO.setBoxId(airSwitchInfoDTO.getBoxId().toString());
+            if (airSwitchInfoDTO.getType() != null && airSwitchInfoDTO.getType() == 1){
+                airSwitchInfoDTO.setType(1);
+                airSwitchDetailVO.setType(airSwitchInfoDTO.getType().toString());
+            }else {
+                airSwitchInfoDTO.setType(0);
+                airSwitchDetailVO.setType(airSwitchInfoDTO.getType().toString());
+            }
+        return airSwitchDetailVO;
+    }
 }

+ 31 - 0
src/main/java/com/welampiot/vo/AirSwitchDetailVO.java

@@ -0,0 +1,31 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: AirSwitchDetailVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/4/3 - 11:41
+ * @Version: v1.0
+ */
+@Data
+public class AirSwitchDetailVO implements Serializable {
+    /** 设备名称 **/
+    private String name;
+
+    /** 电箱id **/
+    private String boxId;
+
+    /** 设备地址 **/
+    private String address;
+
+    /** 设备类型(0 单相,1 三相) **/
+    private String type;
+
+    private static final long serialVersionUID = 1L;
+}

+ 4 - 0
src/main/resources/mapper/AirSwitchInfoMapper.xml

@@ -44,4 +44,8 @@
         select lp.name policyName from loop_policy lp where lp.id = #{policyId}
     </select>
 
+    <select id="getAirSwitchDetailById" resultType="AirSwitchInfoDTO" parameterType="Integer">
+        select a.name,a.box_id boxId,a.address,a.type from air_switch_info a where a.id = #{id}
+    </select>
+
 </mapper>