浏览代码

获取回路详情、回路下拉列表

zhj 2 年之前
父节点
当前提交
46fef642d5

+ 39 - 1
src/main/java/com/welampiot/controller/LoopController.java

@@ -4,6 +4,7 @@ import com.welampiot.common.BaseResult;
 import com.welampiot.dto.LoopDTO;
 import com.welampiot.service.LoopService;
 import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.LoopDetailVO;
 import com.welampiot.vo.LoopVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 /**
  * ClassName: LoopController
@@ -24,7 +26,7 @@ import javax.servlet.http.HttpServletRequest;
  */
 @RestController
 @CrossOrigin
-@RequestMapping("/api/LoopController")
+@RequestMapping("/api/loopController")
 public class LoopController {
 
     @Autowired
@@ -33,6 +35,11 @@ public class LoopController {
     @Autowired
     private ToolUtils toolUtils;
 
+    /**
+     * 获取回路列表
+     * @param request
+     * @return
+     */
     @RequestMapping(value = "/getList", method = RequestMethod.POST)
     public BaseResult<LoopDTO> getList(HttpServletRequest request){
         Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
@@ -50,4 +57,35 @@ public class LoopController {
         return BaseResult.success(loopList);
     }
 
+    /**
+     * 获取回路详情
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/details",method = RequestMethod.POST)
+    public BaseResult<LoopDTO> details(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
+        if (id == 0) return toolUtils.response("0001", version);
+        LoopDetailVO loopDetail = loopService.getLoopDetail(id, version,toolUtils.getSectionList(request));
+        if (loopDetail == null) return toolUtils.response("0001",version);
+        return BaseResult.success(loopDetail);
+    }
+
+    /**
+     * 获取回路下拉列表
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/nav", method = RequestMethod.POST)
+    public BaseResult<LoopDTO> nav(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        List sectionList = toolUtils.getSectionList(request);
+        if (sectionList == null) return toolUtils.response("0001", version);
+        LoopVO loopDropDownList = loopService.getLoopDropDownList(sectionList);
+        LoopVO[] array = {};
+        if (loopDropDownList == null) return BaseResult.success(array);
+        return BaseResult.success(loopDropDownList);
+    }
+
 }

+ 5 - 0
src/main/java/com/welampiot/dao/LoopDao.java

@@ -1,6 +1,7 @@
 package com.welampiot.dao;
 
 import com.welampiot.dto.LoopDTO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,4 +18,8 @@ public interface LoopDao {
     List<LoopDTO> getLoopListByLoopDTO(LoopDTO dto);
 
     Integer getTotalBySectionList(LoopDTO dto);
+
+    LoopDTO getLoopDetailById(@Param("id") Integer id, @Param("sectionList") List<LoopDTO> sectionList);
+
+    List<LoopDTO> getLoopDropDownListBySectionList(@Param("sectionList") List<LoopDTO> sectionList);
 }

+ 15 - 0
src/main/java/com/welampiot/dto/LoopDTO.java

@@ -172,6 +172,21 @@ public class LoopDTO implements Serializable {
     /** 时区 **/
     private Integer timezone;
 
+    /** 市区名称 **/
+    private String area;
+
+    private String chineseName;
+
+    private String englishName;
+
+    private String ruName;
+
+    /** 路段名称 **/
+    private String section;
+
+    /** 费率名称 **/
+    private String rateStr;
+
     /** 页码 **/
     private Integer page;
 

+ 7 - 0
src/main/java/com/welampiot/service/LoopService.java

@@ -1,8 +1,11 @@
 package com.welampiot.service;
 
 import com.welampiot.dto.LoopDTO;
+import com.welampiot.vo.LoopDetailVO;
 import com.welampiot.vo.LoopVO;
 
+import java.util.List;
+
 /**
  * ClassName: LoopService
  * Package: com.welampiot.service
@@ -14,4 +17,8 @@ import com.welampiot.vo.LoopVO;
  */
 public interface LoopService {
     LoopVO getLoopList(LoopDTO dto);
+
+    LoopDetailVO getLoopDetail(Integer id, Integer version, List<LoopDTO> sectionList);
+
+    LoopVO getLoopDropDownList(List<LoopDTO> sectionList);
 }

+ 62 - 0
src/main/java/com/welampiot/service/impl/LoopServiceImpl.java

@@ -3,6 +3,7 @@ package com.welampiot.service.impl;
 import com.welampiot.dao.LoopDao;
 import com.welampiot.dto.LoopDTO;
 import com.welampiot.service.LoopService;
+import com.welampiot.vo.LoopDetailVO;
 import com.welampiot.vo.LoopVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -60,4 +61,65 @@ public class LoopServiceImpl implements LoopService {
         loopVO.setList(list);
         return loopVO;
     }
+
+    @Override
+    public LoopDetailVO getLoopDetail(Integer id,Integer version,List<LoopDTO> sectionList) {
+        LoopDetailVO vo = new LoopDetailVO();
+        LoopDTO dto = loopDao.getLoopDetailById(id,sectionList);
+        if (dto == null) return null;
+            vo.setName(dto.getName());
+            vo.setAreaId(dto.getAreaId().toString());
+            if (dto.getAreaId() != null && dto.getAreaId() != 0){
+                if (version == 0){
+                    dto.setArea(dto.getChineseName());
+                    vo.setArea(dto.getArea());
+                }else if (version == 1){
+                    dto.setArea(dto.getEnglishName());
+                    vo.setArea(dto.getArea());
+                }else {
+                    dto.setArea(dto.getRuName());
+                    vo.setArea(dto.getArea());
+                }
+            }else {
+                vo.setArea("");
+            }
+            vo.setSectionId(dto.getSectionId().toString());
+            if (dto.getSectionId() != null && dto.getSectionId() != 0){
+                vo.setSection(dto.getSection());
+            }else {
+                vo.setSection("");
+            }
+            vo.setNumber(dto.getNumber().toString());
+            vo.setLampCount(dto.getLampCount().toString());
+            vo.setSn(dto.getSn());
+            if (dto.getDevType() != null && dto.getDevType() == 1){
+                dto.setDevType(1);
+                vo.setDevType(dto.getDevType().toString());
+            }else {
+                dto.setDevType(0);
+                vo.setDevType(dto.getDevType().toString());
+            }
+            if (dto.getStatus() != null && dto.getStatus() == 1){
+                dto.setStatus(1);
+                vo.setStatus(dto.getStatus().toString());
+            }else {
+                dto.setStatus(0);
+                vo.setStatus(dto.getStatus().toString());
+            }
+            vo.setRateId(dto.getRateId().toString());
+            if (dto.getRateId() != null && dto.getRateId() != 0){
+                vo.setRateStr(dto.getRateStr());
+            }else {
+                vo.setRateStr("");
+            }
+            vo.setLampPoleId(dto.getLampPoleId().toString());
+        return vo;
+    }
+
+    @Override
+    public LoopVO getLoopDropDownList(List<LoopDTO> sectionList) {
+        LoopVO vo = new LoopVO();
+        vo.setList(loopDao.getLoopDropDownListBySectionList(sectionList));
+        return vo;
+    }
 }

+ 58 - 0
src/main/java/com/welampiot/vo/LoopDetailVO.java

@@ -0,0 +1,58 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: LoopDetailVO
+ * Package: com.welampiot.vo
+ * Description:
+ *
+ * @Author: zhj_Start
+ * @Create: 2023/4/6 - 10:59
+ * @Version: v1.0
+ */
+@Data
+public class LoopDetailVO implements Serializable {
+    /** 回路名称 **/
+    private String name;
+
+    /** 区、县id **/
+    private String areaId;
+
+    /** 街道(路段)id **/
+    private String sectionId;
+
+    /** 市区名称 **/
+    private String area;
+
+    /** 路段名称 **/
+    private String section;
+
+    /** 编号 **/
+    private String number;
+
+    /** 路灯数量 **/
+    private String lampCount;
+
+    /** 回路SN **/
+    private String sn;
+
+    /** 设备类型(0 单相,1 三相)**/
+    private String devType;
+
+    /** 1 开,0 关 **/
+    private String status;
+
+    /** 费率id **/
+    private String rateId;
+
+    /** 费率名称 **/
+    private String rateStr;
+
+    /** 灯杆id **/
+    private String lampPoleId;
+
+    private static final long serialVersionUID = 1L;
+}

+ 27 - 0
src/main/resources/mapper/LoopMapper.xml

@@ -36,4 +36,31 @@
         </if>
     </select>
 
+    <select id="getLoopDetailById" resultType="LoopDTO">
+        select l.name,l.areaid as areaId,l.sectionid as sectionId,l.number,
+               l.lampcount as lampCount,l.sn,l.dev_type as devType,l.status,
+               l.rateid as rateId,l.lamp_pole_id lampPoleId,s.name as section,
+               g.chinese_name chineseName,g.ru_name ruName,g.english_name englishName,r.name rateStr
+        from `loop` l left join section s on l.sectionid = s.id
+            left join global_location g on l.areaid = g.id
+            left join rate r on l.rateid = r.id
+        where l.id = #{id}
+            <if test="sectionList != null and !sectionList.isEmpty()">
+                and l.sectionid in
+                    <foreach item="item" collection="sectionList" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+            </if>
+    </select>
+
+    <select id="getLoopDropDownListBySectionList" resultType="LoopDTO">
+        select l.name,l.id from `loop` l
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where l.sectionid in
+            <foreach item="dto" collection="sectionList" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+    </select>
+
 </mapper>