Selaa lähdekoodia

灯控列表,添加灯控,4G单灯跟双灯

crazycat 2 vuotta sitten
vanhempi
commit
9c9e318147
36 muutettua tiedostoa jossa 1513 lisäystä ja 32 poistoa
  1. 20 0
      src/main/java/com/welampiot/configuration/LampConfig.java
  2. 207 0
      src/main/java/com/welampiot/controller/LampController.java
  3. 26 1
      src/main/java/com/welampiot/controller/LampPoleController.java
  4. 95 8
      src/main/java/com/welampiot/controller/NewLampPoleController.java
  5. 2 0
      src/main/java/com/welampiot/dao/GlobalLocationDao.java
  6. 11 0
      src/main/java/com/welampiot/dao/LampDao.java
  7. 7 0
      src/main/java/com/welampiot/dao/LampInfoLogDao.java
  8. 7 0
      src/main/java/com/welampiot/dao/LampPoleDao.java
  9. 8 0
      src/main/java/com/welampiot/dao/NetworkDao.java
  10. 11 0
      src/main/java/com/welampiot/dto/GlobalLocationDTO.java
  11. 63 0
      src/main/java/com/welampiot/dto/LampInfoDTO.java
  12. 7 0
      src/main/java/com/welampiot/dto/LampInfoLogDTO.java
  13. 14 0
      src/main/java/com/welampiot/dto/LampPoleDTO.java
  14. 18 0
      src/main/java/com/welampiot/dto/NetworkDTO.java
  15. 4 0
      src/main/java/com/welampiot/service/GlobalLocationService.java
  16. 7 0
      src/main/java/com/welampiot/service/LampInfoLogService.java
  17. 6 0
      src/main/java/com/welampiot/service/LampPoleService.java
  18. 13 0
      src/main/java/com/welampiot/service/LampService.java
  19. 8 0
      src/main/java/com/welampiot/service/NetworkService.java
  20. 116 0
      src/main/java/com/welampiot/service/impl/GlobalLocationServiceImpl.java
  21. 16 0
      src/main/java/com/welampiot/service/impl/LampInfoLogServiceImpl.java
  22. 14 0
      src/main/java/com/welampiot/service/impl/LampPoleServiceImpl.java
  23. 243 2
      src/main/java/com/welampiot/service/impl/LampServiceImpl.java
  24. 37 0
      src/main/java/com/welampiot/service/impl/NetworkServiceImpl.java
  25. 11 0
      src/main/java/com/welampiot/vo/GlobalLocationVO.java
  26. 2 0
      src/main/java/com/welampiot/vo/LampCountVO.java
  27. 25 0
      src/main/java/com/welampiot/vo/LampListResponseVO.java
  28. 27 0
      src/main/java/com/welampiot/vo/LampPoleInfoVO.java
  29. 12 0
      src/main/java/com/welampiot/vo/LampPoleVO.java
  30. 30 0
      src/main/resources/config/lamp.yml
  31. 12 1
      src/main/resources/config/response.yml
  32. 53 0
      src/main/resources/mapper/GlobalLocationMapper.xml
  33. 7 0
      src/main/resources/mapper/LampInfoLogMapper.xml
  34. 287 20
      src/main/resources/mapper/LampMapper.xml
  35. 60 0
      src/main/resources/mapper/LampPoleMapper.xml
  36. 27 0
      src/main/resources/mapper/NetworkMapper.xml

+ 20 - 0
src/main/java/com/welampiot/configuration/LampConfig.java

@@ -0,0 +1,20 @@
+package com.welampiot.configuration;
+
+import com.welampiot.common.YamlPropertySourceFactory;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+@Component
+@PropertySource(factory = YamlPropertySourceFactory.class,value = "classpath:config/lamp.yml", encoding = "utf-8")
+@ConfigurationProperties(prefix = "lamp")
+@Data
+public class LampConfig {
+    public Map<Integer, String> controlType;
+}

+ 207 - 0
src/main/java/com/welampiot/controller/LampController.java

@@ -0,0 +1,207 @@
+package com.welampiot.controller;
+
+import com.welampiot.common.BaseResult;
+import com.welampiot.common.ResultEnum;
+import com.welampiot.dto.LampInfoDTO;
+import com.welampiot.dto.NetworkDTO;
+import com.welampiot.service.LampService;
+import com.welampiot.service.NetworkService;
+import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.InfoResponseVO;
+import com.welampiot.vo.LampCountVO;
+import com.welampiot.vo.LampListResponseVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+@RestController
+@CrossOrigin
+@RequestMapping("/lamp")
+public class LampController {
+    @Autowired
+    private LampService lampService;
+    @Autowired
+    private ToolUtils toolUtils;
+    @Autowired
+    private NetworkService networkService;
+
+    /**
+     * 灯控列表
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/getlist",method = RequestMethod.POST)
+    public BaseResult<InfoResponseVO> getList(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        Integer page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
+        Integer count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
+        Integer online = request.getParameter("online") == null || request.getParameter("online") == "" ? null : Integer.parseInt(request.getParameter("online"));
+        Integer light_status = request.getParameter("light_status") == null || request.getParameter("light_status") == "" ? null : Integer.parseInt(request.getParameter("light_status"));
+        String keyword = request.getParameter("keyword") == null ? "" : request.getParameter("keyword");
+        Integer limit = count;
+        Integer offset = (page-1)*count;
+        List sectionList = toolUtils.getSectionList(request);
+        LampListResponseVO lampListResponseVO = new LampListResponseVO();
+        if (keyword.length() > 0) lampListResponseVO.setKeyword(keyword);
+        lampListResponseVO.setSectionList(sectionList);
+        lampListResponseVO.setVersion(version);
+        lampListResponseVO.setLimit(limit);
+        lampListResponseVO.setOffset(offset);
+        if (online != null) lampListResponseVO.setOnline(online);
+        if (light_status != null) lampListResponseVO.setLightStatus(light_status);
+        List<LampInfoDTO> listByVO = lampService.getListByVO(lampListResponseVO);
+        LampListResponseVO lampListResponseVO1 = new LampListResponseVO();
+        lampListResponseVO1.setList(listByVO);
+
+        LampCountVO lampCountVO = new LampCountVO();
+        lampCountVO.setSectionList(sectionList);
+        if (online != null) lampCountVO.setOnlineStatus(online);
+        if (light_status != null) lampCountVO.setLampStatus(light_status);
+        if (keyword.length() > 0) lampCountVO.setKeyword(keyword);
+        Integer countByVO = lampService.getCountByVO(lampCountVO);
+        lampListResponseVO1.setTotal(countByVO/count);
+        lampListResponseVO1.setTotal2(countByVO);
+
+        lampCountVO = new LampCountVO();
+        lampCountVO.setSectionList(sectionList);
+        countByVO = lampService.getCountByVO(lampCountVO);
+        lampListResponseVO1.setDevTotal(countByVO);
+
+        lampCountVO.setOnlineStatus(1);
+        countByVO = lampService.getCountByVO(lampCountVO);
+        lampListResponseVO1.setOnlineCount(countByVO);
+
+        lampCountVO.setLampStatus(1);
+        countByVO = lampService.getCountByVO(lampCountVO);
+        lampListResponseVO1.setLightCount(countByVO);
+
+        lampCountVO.setAlarmStatus(1);
+        lampListResponseVO1.setAlarmCount(countByVO);
+        return BaseResult.success(lampListResponseVO1);
+    }
+
+    /**
+     * 灯控详情
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/details",method = RequestMethod.POST)
+    public BaseResult<LampInfoDTO> details(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        Integer lampId = request.getParameter("lampId") == null ? 0 : Integer.parseInt(request.getParameter("lampId"));
+        LampInfoDTO detailsById = lampService.getDetailsById(lampId,version);
+        return BaseResult.success(detailsById);
+    }
+
+    /**
+     * 添加编辑灯控
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/save",method = RequestMethod.POST)
+    @Transactional
+    public BaseResult save(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        Integer lampId = request.getParameter("lampId") == null || request.getParameter("lampId").length() == 0? 0 : Integer.parseInt(request.getParameter("lampId"));
+        Integer areaId = request.getParameter("areaId") == null ? 0 : Integer.parseInt(request.getParameter("areaId"));
+        Integer sectionId = request.getParameter("sectionId") == null ? 0 : Integer.parseInt(request.getParameter("sectionId"));
+
+        Integer protocolType = request.getParameter("protocolType") == null ? 0 : Integer.parseInt(request.getParameter("protocolType"));
+        Integer controlType = request.getParameter("controlType") == null ? 0 : Integer.parseInt(request.getParameter("controlType"));
+
+        Integer power = request.getParameter("power") == null ? 0 : Integer.parseInt(request.getParameter("power"));
+        String installDate = request.getParameter("install_date") == null ? "" : request.getParameter("install_date");
+        String expirationDate = request.getParameter("expiration_date") == null ? "" : request.getParameter("expiration_date");
+
+        String number = request.getParameter("number");
+        String longitude = request.getParameter("longitude") == null || request.getParameter("longitude").length() == 0 ? "0" : request.getParameter("longitude");
+        String latitude = request.getParameter("latitude") == null || request.getParameter("latitude").length() == 0 ? "0" : request.getParameter("latitude");
+
+        if (number == null || number.length() == 0) return toolUtils.response("0201",version);
+        if (!number.matches("^[A-Za-z0-9]+$")) return toolUtils.response("0202",version);
+        String name = request.getParameter("name");
+        if (name == null || name.length() == 0) return toolUtils.response("0204",version);
+        String sn = request.getParameter("sn");
+        if (sn == null || sn.length() == 0) return toolUtils.response("0206",version);
+
+        if (areaId == 0) return toolUtils.response("0208",version);
+        if (sectionId == 0) return toolUtils.response("0209",version);
+
+
+        if (lampId == 0){  // 添加
+            LampInfoDTO lampInfoDTO = new LampInfoDTO();
+            lampInfoDTO.setProtocolType(protocolType);
+            lampInfoDTO.setSn(sn);
+            lampInfoDTO.setNumber(number);
+            lampInfoDTO.setSectionId(sectionId);
+            lampInfoDTO.setName(name);
+            lampInfoDTO.setLatitude(Float.valueOf(latitude));
+            lampInfoDTO.setLongitude(Float.valueOf(longitude));
+            lampInfoDTO.setNumber(number);
+            lampInfoDTO.setSn(sn);
+            lampInfoDTO.setAreaId(areaId);
+            lampInfoDTO.setControlType(controlType);
+            lampInfoDTO.setInstallDate(installDate);
+            lampInfoDTO.setExpirationDate(expirationDate);
+            lampInfoDTO.setRatedPower(power);
+            return lampService.add(lampInfoDTO);
+        }else { // 编辑
+//            LampInfoDTO oldLamp = lampService.getDetailsById(lampId,version);
+//            if (oldLamp.getProtocolType() != protocolType){
+//                NetworkDTO networkDTO = new NetworkDTO();
+//                networkDTO.setId(oldLamp.getNetworkId());
+//                networkDTO.setNetworkName(sn);
+//                networkDTO.setDeviceSn(sn);
+//                networkDTO.setAreaId(areaId);
+//                networkDTO.setSectionId(sectionId);
+//                if (protocolType == 10) networkDTO.setDeviceType(4);
+//                networkDTO.setProtocolType(protocolType);
+//                networkService.update(networkDTO);
+//            }
+            LampInfoDTO lampInfoDTO = new LampInfoDTO();
+            lampInfoDTO.setId(lampId);
+            lampInfoDTO.setNumber(number);
+            lampInfoDTO.setSectionId(sectionId);
+            lampInfoDTO.setName(name);
+//            lampInfoDTO.setNetworkId(oldLamp.getNetworkId());
+            lampInfoDTO.setLatitude(Float.valueOf(latitude));
+            lampInfoDTO.setLongitude(Float.valueOf(longitude));
+            lampInfoDTO.setNumber(number);
+            lampInfoDTO.setSn(sn);
+            lampInfoDTO.setAreaId(areaId);
+            lampInfoDTO.setControlType(controlType);
+            lampInfoDTO.setProtocolType(protocolType);
+            lampInfoDTO.setInstallDate(installDate);
+            lampInfoDTO.setExpirationDate(expirationDate);
+            lampInfoDTO.setRatedPower(power);
+            return lampService.update(lampInfoDTO);
+        }
+    }
+
+    /**
+     * 删除灯控
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/del",method = RequestMethod.POST)
+    public BaseResult del(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        String lampId = request.getParameter("lampId");
+        if (lampId == null || lampId.length() == 0) return toolUtils.response("0007",version);
+        String[] split = lampId.split(",");
+        for (String id :split) {
+            int l = Integer.parseInt(id);
+            lampService.deleteById(l);
+        }
+        return toolUtils.response("0000",version);
+    }
+}

+ 26 - 1
src/main/java/com/welampiot/controller/LampPoleController.java

@@ -1,9 +1,14 @@
 package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
+import com.welampiot.dto.LampInfoDTO;
+import com.welampiot.dto.LampPoleDTO;
 import com.welampiot.dto.ScreenDTO;
+import com.welampiot.service.LampPoleService;
 import com.welampiot.service.ScreenService;
 import com.welampiot.utils.ToolUtils;
+import com.welampiot.vo.LampPoleVO;
+import com.welampiot.vo.ListResponseVO;
 import com.welampiot.vo.ScreenDetailsVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -12,6 +17,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: LampPoleController
@@ -24,7 +30,7 @@ import javax.servlet.http.HttpServletRequest;
  */
 @RestController
 @CrossOrigin
-@RequestMapping("/api/lampPole")
+@RequestMapping("/lampPole")
 public class LampPoleController {
 
     @Autowired
@@ -33,6 +39,9 @@ public class LampPoleController {
     @Autowired
     private ToolUtils toolUtils;
 
+    @Autowired
+    private LampPoleService lampPoleService;
+
     /**
      * 获取屏幕详情
      * @param request
@@ -51,4 +60,20 @@ public class LampPoleController {
         if (vo == null) return toolUtils.response("0001",version);
         return BaseResult.success(vo);
     }
+
+    @RequestMapping(value = "/nav",method = RequestMethod.POST)
+    public BaseResult<LampInfoDTO> details(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        Integer devType = request.getParameter("devType") == null || request.getParameter("devType").length() == 0 ? null : Integer.parseInt(request.getParameter("devType"));
+        Integer devId = request.getParameter("devId") == null || request.getParameter("devId").length() == 0 ? null : Integer.parseInt(request.getParameter("devId"));
+        LampPoleVO lampPoleVO = new LampPoleVO();
+        List sectionList = toolUtils.getSectionList(request);
+        lampPoleVO.setSectionList(sectionList);
+        if (devType != null) lampPoleVO.setDevType(devType);
+        if (devId != null) lampPoleVO.setDevId(devId);
+        List<LampPoleDTO> navByVO = lampPoleService.getNavByVO(lampPoleVO);
+        ListResponseVO listResponseVO = new ListResponseVO();
+        listResponseVO.setList(navByVO);
+        return BaseResult.success(listResponseVO);
+    }
 }

+ 95 - 8
src/main/java/com/welampiot/controller/NewLampPoleController.java

@@ -1,14 +1,8 @@
 package com.welampiot.controller;
 
 import com.welampiot.common.BaseResult;
-import com.welampiot.dto.EnvmonitorDTO;
-import com.welampiot.dto.ScreenDTO;
-import com.welampiot.dto.WifiDTO;
-import com.welampiot.dto.WifiInfoLogDTO;
-import com.welampiot.service.EnvmonitorService;
-import com.welampiot.service.ScreenService;
-import com.welampiot.service.WifiInfoLogService;
-import com.welampiot.service.WifiService;
+import com.welampiot.dto.*;
+import com.welampiot.service.*;
 import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * ClassName: NewLampPoleController
@@ -48,6 +44,97 @@ public class NewLampPoleController {
     @Autowired
     private ToolUtils toolUtils;
 
+    @Autowired
+    private LampPoleService lampPoleService;
+
+    @RequestMapping(value = "/info",method = RequestMethod.POST)
+    public BaseResult info(HttpServletRequest request){
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+
+        LampPoleInfoVO lampPoleInfoVO = new LampPoleInfoVO();
+        List sectionList = toolUtils.getSectionList(request);
+        LampPoleVO lampPoleVO = new LampPoleVO();
+        lampPoleVO.setSectionList(sectionList);
+        List<LampPoleDTO> listByVO = lampPoleService.getListByVO(lampPoleVO);
+        lampPoleInfoVO.setDeviceCount(listByVO.size());
+        lampPoleInfoVO.setRunCount(listByVO.size());
+        lampPoleInfoVO.setWifiCount(listByVO.size());
+        lampPoleInfoVO.setEmCount(0);
+        for (LampPoleDTO l:listByVO) {
+            String devType = l.getDevType();
+            List split = Arrays.asList(devType.split(","));
+            if (split.contains("5")) lampPoleInfoVO.setEmCount(lampPoleInfoVO.getEmCount()+1);;
+        }
+//        $data['loopCount'] = $this->Loop_model->get_count(array('sectionid'=>$sectionId));
+//        $id_arr = array_column($lampPoleList, 'id');
+//        $temp_l = [];
+//        if (!empty($id_arr)) {
+//            $sql = 'select lamp_pole_id,max(updatetime),status,id,devtype from lamp_pole_alarm_log where lamp_pole_id in ('.implode(',', $id_arr).') and (status = 0 or status = 1) group by lamp_pole_id';
+//            $l_list = $this->db->query($sql)->result_array();
+//            foreach ($l_list as $key => $value) {
+//                // if ($value['status'] != 1 && $value['status'] != 0) continue;
+//                $temp_l[$value['lamp_pole_id']] = $value;
+//            }
+//        }
+//
+//        $lampPoleId = array();
+//        foreach ($lampPoleList as $lampPole) {
+//            $data['deviceCount'] += 1;
+//            $data['runCount'] += 1;
+//            if (time() - strtotime($lampPole['createtime']) <= 3600*24*30) {
+//                $data['newCount'] += 1;
+//            }
+//            $typeArr = explode(',', $lampPole['devtype']);
+//            if (in_array('0', $typeArr)) $data['lampCount'] += 1;
+//            if (in_array('1', $typeArr)) $data['videoCount'] += 1;
+//            if (in_array('2', $typeArr)) $data['wifiCount'] += 1;
+//            if (in_array('4', $typeArr)) $data['screenCount'] += 1;
+//            if (in_array('5', $typeArr)) $data['emCount'] += 1;
+//            if (in_array('6', $typeArr)) $data['chargeCount'] += 1;
+//            if (in_array('7', $typeArr)) $data['weatherCount'] += 1;
+//            if (in_array('9', $typeArr)) $data['radioCount'] += 1;
+//            if (in_array('14', $typeArr)) $data['waterImmersionCount'] += 1;
+//            if (in_array('18', $typeArr)) $data['tiltCount'] += 1;
+//            if (in_array('15', $typeArr)) $data['lockCount'] += 1;
+//            if (isset($temp_l[$lampPole['id']])) {
+//                $data['faultCount'] += 1;
+//                $data['runCount'] -= 1;
+//            }
+//
+//            $lampPoleId[] = $lampPole['id'];
+//        }
+//
+//        if (!empty($lampPoleId)) {
+//            // smart_lock_dev_info
+//            $res = $this->db->query('select count(*) as total from smart_lock_dev_info where lamp_pole_id in ('.implode(',', $lampPoleId).')')->row_array();
+//            $data['lockCount'] = intval($res['total']);
+//
+//            $lampinfoList = $this->Lampinfo_model->get_list(array('lamp_pole_id'=>$lampPoleId),'id');
+//            $lampId = array();
+//            $data['lampCount'] = count($lampinfoList);
+//            foreach ($lampinfoList as $l) {
+//                $lampId[] = $l['id'];
+//            }
+//            if (!empty($lampId)) {
+//                $join = array(
+//                        array('table'=>'lamp_info_log_new as t1','cond'=>'t1.updatetime = LI.updatetime AND t1.lampid = LI.lampid','type'=>'inner')
+//                );
+//                $sql = "select day_gener_energy,month_gener_energy,used_energy_total from lamp_info_log_new a where a.lampid in (".implode(',', $lampId).")";
+//                $lampInfoLogList = $this->db->query($sql)->result_array();
+//                foreach ($lampInfoLogList as $lampLog) {
+//                    $data['dayCom'] += $lampLog['day_gener_energy'];
+//                    $data['monthCom'] += $lampLog['month_gener_energy'];
+//                    $data['totalCom'] += $lampLog['used_energy_total'];
+//                }
+//            }
+//        }
+//        $data['dayCom'] = round($data['dayCom'],1);
+//        $data['monthCom'] = round($data['monthCom'],1);
+//        $data['totalCom'] = round($data['totalCom'],1);
+
+        return toolUtils.response("0000",version,lampPoleInfoVO);
+    }
+
     /**
      * 获取云盒列表
      * @param request

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

@@ -1,6 +1,7 @@
 package com.welampiot.dao;
 
 import com.welampiot.dto.GlobalLocationDTO;
+import com.welampiot.vo.GlobalLocationVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -21,4 +22,5 @@ public interface GlobalLocationDao {
 
     List<GlobalLocationDTO> getListByPid(@Param("pid") Integer pid);
     List<GlobalLocationDTO> getListByPidList(@Param("pids") List pids);
+    List<GlobalLocationDTO> getUserProvinceNav(GlobalLocationVO globalLocationVO);
 }

+ 11 - 0
src/main/java/com/welampiot/dao/LampDao.java

@@ -1,7 +1,10 @@
 package com.welampiot.dao;
 
+import com.welampiot.dto.LampInfoDTO;
 import com.welampiot.vo.LampCountVO;
+import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -10,4 +13,12 @@ public interface LampDao {
     Float getDayConsumptionByVO(LampCountVO lampCountVO);
     Float getConsumptionByVO(LampCountVO lampCountVO);
     List<LampLogVO> getConsumptionListByVO(LampCountVO lampCountVO);
+    List<LampInfoDTO> getListByVO(LampListResponseVO lampListResponseVO);
+    LampInfoDTO getDetailsById(@Param("id")Integer id,@Param("version")Integer version);
+    LampInfoDTO getDetailsByAddress(@Param("address")String address,@Param("version")Integer version);
+    Integer findByVO(LampInfoDTO lampInfoDTO);
+    Integer checkData(LampInfoDTO lampInfoDTO);
+    Integer add(LampInfoDTO lampInfoDTO);
+    Integer update(LampInfoDTO lampInfoDTO);
+    Integer deleteById(@Param("id")Integer id);
 }

+ 7 - 0
src/main/java/com/welampiot/dao/LampInfoLogDao.java

@@ -0,0 +1,7 @@
+package com.welampiot.dao;
+
+import org.apache.ibatis.annotations.Param;
+
+public interface LampInfoLogDao {
+    Integer deleteByLampId(@Param("lampId")Integer lampId);
+}

+ 7 - 0
src/main/java/com/welampiot/dao/LampPoleDao.java

@@ -1,7 +1,14 @@
 package com.welampiot.dao;
 
+import com.welampiot.dto.LampPoleDTO;
 import com.welampiot.vo.LampPoleCountVO;
+import com.welampiot.vo.LampPoleVO;
+
+import java.util.List;
 
 public interface LampPoleDao {
     Integer getCountByVO(LampPoleCountVO lampPoleCountVO);
+    List<LampPoleDTO> getNavByVO(LampPoleVO lampPoleVO);
+
+    List<LampPoleDTO> getListByVO(LampPoleVO lampPoleVO);
 }

+ 8 - 0
src/main/java/com/welampiot/dao/NetworkDao.java

@@ -0,0 +1,8 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.NetworkDTO;
+
+public interface NetworkDao {
+    Integer add(NetworkDTO networkDTO);
+    Integer update(NetworkDTO networkDTO);
+}

+ 11 - 0
src/main/java/com/welampiot/dto/GlobalLocationDTO.java

@@ -16,6 +16,9 @@ import java.io.Serializable;
 @Data
 public class GlobalLocationDTO implements Serializable {
     private Integer id;//主键
+    private Integer id1;
+    private Integer id2;
+    private Integer id3;
 
     private String chineseName;//中文名称
 
@@ -26,6 +29,9 @@ public class GlobalLocationDTO implements Serializable {
     private Integer childCount;//下级区域数量
 
     private Integer level;//区域等级
+    private Integer level1;//区域等级
+    private Integer level2;//区域等级
+    private Integer level3;//区域等级
 
     private String code;//区域编码
 
@@ -41,5 +47,10 @@ public class GlobalLocationDTO implements Serializable {
 
     private Double latitude;//纬度
 
+    private String name;
+    private String name1;
+    private String name2;
+    private String name3;
+
     private static final long serialVersionUID = 1L;
 }

+ 63 - 0
src/main/java/com/welampiot/dto/LampInfoDTO.java

@@ -0,0 +1,63 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class LampInfoDTO {
+    private Integer id;
+    private String number;
+    private String sn;
+    private String area;
+    private Integer areaId;
+    private String section;
+    private Integer sectionId;
+    private Integer timezone;
+    private String lighteness;
+    private String name;
+    private String voltage;
+    private String current;
+    private String power;
+    private Integer lightTime;
+    private Float totalEnergy;
+    private String cmdTime;
+    private Integer ledLuxValue;
+    private Float leakageCur;
+    private String networkStatus;
+    private String lampStatus;
+    private String lampOnline;
+    private Integer rssi;
+    private Integer snr;
+    private int protocolType;
+    private String groupId;
+    private String group;
+    private String network;
+    private int networkId;
+    private String netStatus;
+    private String lampPoleName;
+    private String loopNumber;
+    private String updateTime;
+    private Integer faultstatus;
+    private Integer mode;
+    private String hwVersion;
+    private String swVersion;
+    private int controlType;
+    private String macAddress;
+    private String devAddr;
+    private Integer bindStatus;
+    private Integer policyType;
+    private Integer policyid;
+    private Float longitude;
+    private Float latitude;
+    private Integer newFaultstatus;
+    private String installDate;
+    private String expirationDate;
+    private String policyName;
+    private Integer alarmStatus;
+    private Integer alarmid;
+    private String stralarmtype;
+    private String dueDate;
+    private String controlTypeStr;
+    private String createTime;
+    private int ratedPower;
+    private int version;
+}

+ 7 - 0
src/main/java/com/welampiot/dto/LampInfoLogDTO.java

@@ -0,0 +1,7 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class LampInfoLogDTO {
+}

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

@@ -0,0 +1,14 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class LampPoleDTO {
+    private Integer id;
+    private String name;
+    private Float longitude;
+    private Float latitude;
+    private String devType;
+    private String createtime;
+    private Integer online;
+}

+ 18 - 0
src/main/java/com/welampiot/dto/NetworkDTO.java

@@ -0,0 +1,18 @@
+package com.welampiot.dto;
+
+import lombok.Data;
+
+@Data
+public class NetworkDTO {
+    private int id;
+    private String gatewayType;  // 网关类型
+    private int protocolType;  // 协议类型
+    private int areaId;  // 区域id
+    private int sectionId;  // 路段id
+    private String deviceSn;  // sn 地址
+    private int deviceType;  // 设备型号
+    private String networkName;  // 网络名称
+    private int netType;  // 网落类型 0 组网,1直连
+    private String createTime;  // 创建时间
+    private int userId;  // 创建人
+}

+ 4 - 0
src/main/java/com/welampiot/service/GlobalLocationService.java

@@ -1,6 +1,7 @@
 package com.welampiot.service;
 
 import com.welampiot.dto.GlobalLocationDTO;
+import com.welampiot.vo.GlobalLocationVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -20,4 +21,7 @@ public interface GlobalLocationService {
     List<GlobalLocationDTO> getAreaByLevelAndPid(Integer version, Integer level, Integer pid);
     List<GlobalLocationDTO> getListByPid(Integer pid);
     List<GlobalLocationDTO> getListByPidList(List pids);
+    List<GlobalLocationDTO> getUserProvinceNav(GlobalLocationVO globalLocationVO);
+    List<GlobalLocationDTO> getUserCityNav(GlobalLocationVO globalLocationVO);
+    List<GlobalLocationDTO> getUserAreaNav(GlobalLocationVO globalLocationVO);
 }

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

@@ -0,0 +1,7 @@
+package com.welampiot.service;
+
+import org.apache.ibatis.annotations.Param;
+
+public interface LampInfoLogService {
+    Integer deleteByLampId(Integer lampId);
+}

+ 6 - 0
src/main/java/com/welampiot/service/LampPoleService.java

@@ -1,7 +1,13 @@
 package com.welampiot.service;
 
+import com.welampiot.dto.LampPoleDTO;
 import com.welampiot.vo.LampPoleCountVO;
+import com.welampiot.vo.LampPoleVO;
+
+import java.util.List;
 
 public interface LampPoleService {
     Integer getCountByVO(LampPoleCountVO lampPoleCountVO);
+    List<LampPoleDTO> getNavByVO(LampPoleVO lampPoleVO);
+    List<LampPoleDTO> getListByVO(LampPoleVO lampPoleVO);
 }

+ 13 - 0
src/main/java/com/welampiot/service/LampService.java

@@ -1,7 +1,11 @@
 package com.welampiot.service;
 
+import com.welampiot.common.BaseResult;
+import com.welampiot.dto.LampInfoDTO;
 import com.welampiot.vo.LampCountVO;
+import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -10,4 +14,13 @@ public interface LampService {
     Float getDayConsumptionByVO(LampCountVO lampCountVO);  // 查询用电量
     Float getConsumptionByVO(LampCountVO lampCountVO);  // 查询当天用电量
     List<LampLogVO> getConsumptionListByVO(LampCountVO lampCountVO);
+    List<LampInfoDTO> getListByVO(LampListResponseVO lampListResponseVO);
+    LampInfoDTO getDetailsById(Integer id,Integer version);
+    Integer findByVO(LampInfoDTO lampInfoDTO);
+    Integer checkData(LampInfoDTO lampInfoDTO);
+    BaseResult add(LampInfoDTO lampInfoDTO);
+    BaseResult update(LampInfoDTO lampInfoDTO);
+    Integer deleteById(@Param("id")Integer id);
+
+    LampInfoDTO getDetailsByAddress(@Param("address")String address,@Param("version")Integer version);
 }

+ 8 - 0
src/main/java/com/welampiot/service/NetworkService.java

@@ -0,0 +1,8 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.NetworkDTO;
+
+public interface NetworkService {
+    Integer add(NetworkDTO networkDTO);
+    Integer update(NetworkDTO networkDTO);
+}

+ 116 - 0
src/main/java/com/welampiot/service/impl/GlobalLocationServiceImpl.java

@@ -3,10 +3,12 @@ package com.welampiot.service.impl;
 import com.welampiot.dao.GlobalLocationDao;
 import com.welampiot.dto.GlobalLocationDTO;
 import com.welampiot.service.GlobalLocationService;
+import com.welampiot.vo.GlobalLocationVO;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -39,4 +41,118 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
 
     @Override
     public List<GlobalLocationDTO> getListByPidList(List pids) {return globalLocationDao.getListByPidList(pids);}
+
+    @Override
+    public List<GlobalLocationDTO> getUserProvinceNav(GlobalLocationVO globalLocationVO) {
+        List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
+        List<GlobalLocationDTO> data = new ArrayList<>();
+        List<Integer> idList = new ArrayList<>();
+        for (GlobalLocationDTO g:userProvinceNav) {
+            if (g.getLevel1() != null && g.getLevel1() == 2){
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }else if (g.getLevel2() != null && g.getLevel2() == 2){
+                g.setName(g.getName2());
+                g.setName2(null);
+                g.setId(g.getId2());
+                g.setId2(null);
+            }else if (g.getLevel3() != null && g.getLevel3() == 2){
+                g.setName(g.getName3());
+                g.setName3(null);
+                g.setId(g.getId3());
+                g.setId3(null);
+            }else if (g.getLevel1() != null && g.getLevel1() == 1){
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }
+            if (g.getId() != null) {
+                if (!idList.contains(g.getId())){
+                    data.add(g);
+                    idList.add(g.getId());
+                }
+            }
+        }
+
+        return data;
+    }
+
+    @Override
+    public List<GlobalLocationDTO> getUserCityNav(GlobalLocationVO globalLocationVO) {
+        List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
+        List<GlobalLocationDTO> data = new ArrayList<>();
+        List<Integer> idList = new ArrayList<>();
+        for (GlobalLocationDTO g:userProvinceNav) {
+            if (g.getLevel1() != null && g.getLevel1() == 3){
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }else if (g.getLevel2() != null && g.getLevel2() == 3){
+                g.setName(g.getName2());
+                g.setName2(null);
+                g.setId(g.getId2());
+                g.setId2(null);
+            }else if (g.getLevel3() != null && g.getLevel3() == 3){
+                g.setName(g.getName3());
+                g.setName3(null);
+                g.setId(g.getId3());
+                g.setId3(null);
+            }else{
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }
+            if (g.getId() != null) {
+                if (!idList.contains(g.getId())){
+                    data.add(g);
+                    idList.add(g.getId());
+                }
+            }
+        }
+
+        return data;
+    }
+
+    @Override
+    public List<GlobalLocationDTO> getUserAreaNav(GlobalLocationVO globalLocationVO) {
+        List<GlobalLocationDTO> userProvinceNav = globalLocationDao.getUserProvinceNav(globalLocationVO);
+        List<GlobalLocationDTO> data = new ArrayList<>();
+        List<Integer> idList = new ArrayList<>();
+        for (GlobalLocationDTO g:userProvinceNav) {
+            if (g.getLevel1() != null && g.getLevel1() == 4){
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }else if (g.getLevel2() != null && g.getLevel2() == 4){
+                g.setName(g.getName2());
+                g.setName2(null);
+                g.setId(g.getId2());
+                g.setId2(null);
+            }else if (g.getLevel3() != null && g.getLevel3() == 4){
+                g.setName(g.getName3());
+                g.setName3(null);
+                g.setId(g.getId3());
+                g.setId3(null);
+            }else{
+                g.setName(g.getName1());
+                g.setName1(null);
+                g.setId(g.getId1());
+                g.setId1(null);
+            }
+            if (g.getId() != null) {
+                if (!idList.contains(g.getId())){
+                    data.add(g);
+                    idList.add(g.getId());
+                }
+            }
+        }
+
+        return data;
+    }
 }

+ 16 - 0
src/main/java/com/welampiot/service/impl/LampInfoLogServiceImpl.java

@@ -0,0 +1,16 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.LampInfoLogDao;
+import com.welampiot.service.LampInfoLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class LampInfoLogServiceImpl implements LampInfoLogService {
+    @Autowired
+    private LampInfoLogDao lampInfoLogDao;
+    @Override
+    public Integer deleteByLampId(Integer lampId) {
+        return lampInfoLogDao.deleteByLampId(lampId);
+    }
+}

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

@@ -1,15 +1,29 @@
 package com.welampiot.service.impl;
 
 import com.welampiot.dao.LampPoleDao;
+import com.welampiot.dto.LampPoleDTO;
 import com.welampiot.service.LampPoleService;
 import com.welampiot.vo.LampPoleCountVO;
+import com.welampiot.vo.LampPoleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class LampPoleServiceImpl implements LampPoleService {
     @Autowired
     private LampPoleDao lampPoleDao;
     @Override
     public Integer getCountByVO(LampPoleCountVO lampPoleCountVO) {return lampPoleDao.getCountByVO(lampPoleCountVO);}
+
+    @Override
+    public List<LampPoleDTO> getNavByVO(LampPoleVO lampPoleVO) {
+        return lampPoleDao.getNavByVO(lampPoleVO);
+    }
+
+    @Override
+    public List<LampPoleDTO> getListByVO(LampPoleVO lampPoleVO) {
+        return lampPoleDao.getListByVO(lampPoleVO);
+    }
 }

+ 243 - 2
src/main/java/com/welampiot/service/impl/LampServiceImpl.java

@@ -1,28 +1,269 @@
 package com.welampiot.service.impl;
 
+import com.welampiot.common.BaseResult;
+import com.welampiot.configuration.LampConfig;
 import com.welampiot.dao.LampDao;
+import com.welampiot.dto.LampInfoDTO;
+import com.welampiot.dto.NetworkDTO;
+import com.welampiot.service.LampInfoLogService;
 import com.welampiot.service.LampService;
+import com.welampiot.service.NetworkService;
+import com.welampiot.utils.ToolUtils;
 import com.welampiot.vo.LampCountVO;
+import com.welampiot.vo.LampListResponseVO;
 import com.welampiot.vo.LampLogVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Formatter;
 import java.util.List;
 
 @Service
 public class LampServiceImpl implements LampService {
     @Autowired
     private LampDao lampDao;
+    @Autowired
+    private LampConfig lampConfig;
+    @Autowired
+    private ToolUtils toolUtils;
+    @Autowired
+    private LampInfoLogService lampInfoLogService;
+    @Autowired
+    private NetworkService networkService;
     @Override
     public Integer getCountByVO(LampCountVO lampCountVO) {return lampDao.getCountByVO(lampCountVO);}
 
     @Override
-    public Float getDayConsumptionByVO(LampCountVO lampCountVO) {return lampDao.getDayConsumptionByVO(lampCountVO);}
+    public Float getDayConsumptionByVO(LampCountVO lampCountVO) {
+        Float dayConsumptionByVO = lampDao.getDayConsumptionByVO(lampCountVO);
+        dayConsumptionByVO = dayConsumptionByVO == null ? 0 : dayConsumptionByVO;
+        return dayConsumptionByVO;
+    }
 
     @Override
-    public Float getConsumptionByVO(LampCountVO lampCountVO) {return lampDao.getConsumptionByVO(lampCountVO);}
+    public Float getConsumptionByVO(LampCountVO lampCountVO) {
+        Float consumptionByVO = lampDao.getConsumptionByVO(lampCountVO);
+        consumptionByVO = consumptionByVO == null ? 0 : consumptionByVO;
+        return consumptionByVO;
+    }
 
     @Override
     public List<LampLogVO> getConsumptionListByVO(LampCountVO lampCountVO) {return lampDao.getConsumptionListByVO(lampCountVO);}
 
+    @Override
+    public List<LampInfoDTO> getListByVO(LampListResponseVO lampListResponseVO) {
+        List<LampInfoDTO> listByVO = lampDao.getListByVO(lampListResponseVO);
+        List<LampInfoDTO> list = new ArrayList<>();
+        for (LampInfoDTO lamp :listByVO) {
+            if (lamp.getCurrent() != null) {
+                if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){
+                    lamp.setCurrent(String.valueOf((Math.round((Float.parseFloat(lamp.getCurrent()))*100)/100f)));
+                }else {
+                    lamp.setCurrent("0");
+                }
+            }else {
+                lamp.setCurrent("");
+            }
+            if (lamp.getVoltage() != null) {
+                if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){
+                    lamp.setVoltage(String.valueOf((Math.round((Float.parseFloat(lamp.getVoltage()))*100)/100f)));
+                }else {
+                    lamp.setCurrent("0");
+                }
+            }else {
+                lamp.setVoltage("");
+            }
+            if (lamp.getPower() != null) {
+                if (Math.abs(Float.parseFloat(lamp.getCurrent())) >= 0.01){
+                    lamp.setPower(String.valueOf((Math.round((Float.parseFloat(lamp.getPower()))*100)/100f)));
+                }else {
+                    lamp.setCurrent("0");
+                }
+            }else {
+                lamp.setPower("");
+            }
+            if (lamp.getLedLuxValue() == null){
+                lamp.setLedLuxValue(0);
+            }
+            if (Integer.parseInt(lamp.getNetworkStatus()) == 0){
+                lamp.setLighteness("0");
+            }
+            if (lamp.getPolicyName() == null || lamp.getPolicyType() != 1){
+                lamp.setPolicyName("暂无");
+            }
+            if (lampConfig.getControlType().containsKey(lamp.getControlType())){
+                lamp.setControlTypeStr(lampConfig.getControlType().get(lamp.getControlType()));
+            }else {
+                lamp.setControlTypeStr("");
+            }
+            if (lamp.getControlType() == 5){
+                if (lamp.getMode() == 0){
+                    lamp.setNumber(lamp.getNumber()+"-1");
+                }else {
+                    lamp.setNumber(lamp.getNumber()+"-2");
+                }
+            }
+            list.add(lamp);
+        }
+        return list;
+    }
+
+    @Override
+    public LampInfoDTO getDetailsById(Integer id,Integer version) {
+        LampInfoDTO detailsById = lampDao.getDetailsById(id,version);
+        return detailsById;
+    }
+
+    @Override
+    public Integer findByVO(LampInfoDTO lampInfoDTO) {
+        return lampDao.findByVO(lampInfoDTO);
+    }
+
+    @Override
+    public Integer checkData(LampInfoDTO lampInfoDTO) {
+        Integer integer = lampDao.checkData(lampInfoDTO);
+        if (integer == null) integer = 0;
+        return integer;
+    }
+
+    @Override
+    public BaseResult add(LampInfoDTO lampInfoDTO) {
+        LampInfoDTO lampInfoDTO1 = new LampInfoDTO();
+        lampInfoDTO1.setSn(lampInfoDTO.getSn());
+        if (lampDao.findByVO(lampInfoDTO1) > 0) return toolUtils.response("0207",lampInfoDTO.getVersion());
+        lampInfoDTO1 = new LampInfoDTO();
+        lampInfoDTO1.setNumber(lampInfoDTO.getNumber());
+        lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId());
+        if (lampDao.findByVO(lampInfoDTO1) > 0) return toolUtils.response("0203",lampInfoDTO.getVersion());
+        lampInfoDTO1 = new LampInfoDTO();
+        lampInfoDTO1.setName(lampInfoDTO.getName());
+        lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId());
+        if (lampDao.findByVO(lampInfoDTO) > 0) return toolUtils.response("0205",lampInfoDTO.getVersion());
+
+        NetworkDTO networkDTO = new NetworkDTO();
+        networkDTO.setNetworkName(lampInfoDTO.getSn());
+        networkDTO.setDeviceSn(lampInfoDTO.getSn());
+        networkDTO.setAreaId(lampInfoDTO.getAreaId());
+        networkDTO.setSectionId(lampInfoDTO.getSectionId());
+        networkDTO.setNetType(1);
+        networkDTO.setGatewayType("direct");
+        if (lampInfoDTO.getProtocolType() == 10) networkDTO.setDeviceType(4);
+        networkDTO.setProtocolType(lampInfoDTO.getProtocolType());
+        networkService.add(networkDTO);
+
+        lampInfoDTO.setNetworkId(networkDTO.getId());
+        Date endDate = new Date(System.currentTimeMillis());
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String createTime = simpleDateFormat.format(endDate).toString();
+        lampInfoDTO.setCreateTime(createTime);
+        if (lampInfoDTO.getControlType() == 5 || lampInfoDTO.getControlType() == 6 || lampInfoDTO.getControlType() == 7){
+            lampInfoDTO.setMode(1);
+        }
+        lampDao.add(lampInfoDTO);
+
+        if (lampInfoDTO.getControlType() == 5){  // 4G 双灯
+            lampInfoDTO.setMode(0);
+            lampDao.add(lampInfoDTO);
+        }
+        return toolUtils.response("0000",lampInfoDTO.getVersion());
+    }
+
+    @Override
+    public BaseResult update(LampInfoDTO lampInfoDTO) {
+        LampInfoDTO oldLamp = lampDao.getDetailsById(lampInfoDTO.getId(),lampInfoDTO.getVersion());
+        lampInfoDTO.setNetworkId(oldLamp.getNetworkId());
+        LampInfoDTO lampInfoDTO1 = new LampInfoDTO();
+//        lampInfoDTO1.
+        lampInfoDTO1.setSn(lampInfoDTO.getSn());
+        lampInfoDTO1.setId(lampInfoDTO.getId());
+        lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId());
+        if (this.checkData(lampInfoDTO1) > 0) return toolUtils.response("0207",lampInfoDTO.getVersion());
+        lampInfoDTO1 = new LampInfoDTO();
+        lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId());
+        lampInfoDTO1.setNumber(lampInfoDTO.getNumber());
+        lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId());
+        if (this.checkData(lampInfoDTO1) > 0) return toolUtils.response("0203",lampInfoDTO.getVersion());
+        lampInfoDTO1 = new LampInfoDTO();
+        lampInfoDTO1.setNetworkId(lampInfoDTO.getNetworkId());
+        lampInfoDTO1.setName(lampInfoDTO.getName());
+        lampInfoDTO1.setSectionId(lampInfoDTO.getSectionId());
+        if (this.checkData(lampInfoDTO) > 0) return toolUtils.response("0205",lampInfoDTO.getVersion());
+
+
+        if (oldLamp.getProtocolType() != lampInfoDTO.getProtocolType()){
+            NetworkDTO networkDTO = new NetworkDTO();
+            networkDTO.setId(oldLamp.getNetworkId());
+            networkDTO.setNetworkName(lampInfoDTO.getSn());
+            networkDTO.setDeviceSn(lampInfoDTO.getSn());
+            networkDTO.setAreaId(lampInfoDTO.getAreaId());
+            networkDTO.setSectionId(lampInfoDTO.getSectionId());
+            networkDTO.setDeviceType(0);
+            if (lampInfoDTO.getProtocolType() == 10) networkDTO.setDeviceType(4);
+            networkDTO.setProtocolType(lampInfoDTO.getProtocolType());
+            networkService.update(networkDTO);
+        }
+
+        if (lampInfoDTO.getControlType() == 5 || lampInfoDTO.getControlType() == 6 || lampInfoDTO.getControlType() == 7){
+            lampInfoDTO.setMode(oldLamp.getMode());
+        }
+        lampDao.update(lampInfoDTO);
+        System.out.println(lampInfoDTO.getMode());
+        if (lampInfoDTO.getControlType() == 5){  // 4G 双灯
+            lampInfoDTO1 = new LampInfoDTO();
+            lampInfoDTO1.setSn(lampInfoDTO.getSn());
+            lampInfoDTO1.setId(lampInfoDTO.getId());
+            Integer lampId = this.checkData(lampInfoDTO1);
+            if (oldLamp.getMode() == null || oldLamp.getMode() == 0){
+                lampInfoDTO.setMode(1);
+            }else {
+                lampInfoDTO.setMode(0);
+            }
+            System.out.println(lampInfoDTO.getMode());
+            if (lampId > 0){
+                lampInfoDTO.setId(lampId);
+                lampDao.update(lampInfoDTO);
+            }else {
+                Date endDate = new Date(System.currentTimeMillis());
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String createTime = simpleDateFormat.format(endDate).toString();
+                lampInfoDTO.setCreateTime(createTime);
+                lampDao.add(lampInfoDTO);
+            }
+        }else {
+            if (oldLamp.getProtocolType() == 5){
+                lampInfoDTO1 = new LampInfoDTO();
+                lampInfoDTO1.setSn(lampInfoDTO.getSn());
+                lampInfoDTO1.setId(lampInfoDTO.getId());
+                Integer lampId = this.checkData(lampInfoDTO1);
+                System.out.println(lampId);
+                return toolUtils.response("0007",lampInfoDTO.getVersion());
+//                if (lampId > 0){
+//                    lampDao.deleteById(lampId);
+//                }
+            }
+        }
+        return toolUtils.response("0000",lampInfoDTO.getVersion());
+    }
+
+    @Override
+    public Integer deleteById(Integer id) {
+        LampInfoDTO detailsById = this.getDetailsById(id, 0);
+
+        lampInfoLogService.deleteByLampId(id);
+        Integer integer = lampDao.deleteById(id);
+        if (detailsById.getControlType() == 5){  // 4G 双灯
+            LampInfoDTO detailsByAddress = this.getDetailsByAddress(detailsById.getSn(), 0);
+            lampInfoLogService.deleteByLampId(detailsByAddress.getId());
+            lampDao.deleteById(detailsByAddress.getId());
+        }
+        return integer;
+    }
+
+    @Override
+    public LampInfoDTO getDetailsByAddress(String address, Integer version) {
+        return lampDao.getDetailsByAddress(address,version);
+    }
 }

+ 37 - 0
src/main/java/com/welampiot/service/impl/NetworkServiceImpl.java

@@ -0,0 +1,37 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.NetworkDao;
+import com.welampiot.dto.NetworkDTO;
+import com.welampiot.service.NetworkService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Service
+public class NetworkServiceImpl implements NetworkService {
+    @Autowired
+    private NetworkDao networkDao;
+    @Override
+    public Integer add(NetworkDTO networkDTO) {
+//        networkDTO.setNetworkName(lampInfoDTO.getSn());
+//        networkDTO.setDeviceSn(lampInfoDTO.getSn());
+//        networkDTO.setAreaId(lampInfoDTO.getAreaId());
+//        networkDTO.setSectionId(lampInfoDTO.getSectionId());
+
+        Date endDate = new Date(System.currentTimeMillis());
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        String createTime = simpleDateFormat.format(endDate).toString();
+        networkDTO.setCreateTime(createTime);
+        networkDTO.setGatewayType("direct");
+//        if (lampInfoDTO.get == 10) networkDTO.setDeviceType(4);
+//        networkDTO.setProtocolType(protocolType);
+        return networkDao.add(networkDTO);
+    }
+
+    @Override
+    public Integer update(NetworkDTO networkDTO) {
+        return networkDao.update(networkDTO);
+    }
+}

+ 11 - 0
src/main/java/com/welampiot/vo/GlobalLocationVO.java

@@ -0,0 +1,11 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GlobalLocationVO {
+    private List sectionList;
+    private Integer version;
+}

+ 2 - 0
src/main/java/com/welampiot/vo/LampCountVO.java

@@ -8,8 +8,10 @@ import java.util.List;
 public class LampCountVO {
     private Integer onlineStatus; // 在线状态筛选
     private Integer lampStatus; // 开关灯状态筛选
+    private Integer alarmStatus; // 开关灯状态筛选
     private List sectionList; // 路段筛选
     private String startDate; // 开始时间
     private String endDate; // 结束时间
     private String test; // 结束时间
+    private String keyword;
 }

+ 25 - 0
src/main/java/com/welampiot/vo/LampListResponseVO.java

@@ -0,0 +1,25 @@
+package com.welampiot.vo;
+
+import com.welampiot.dto.LampInfoDTO;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LampListResponseVO {
+    private Integer lightStatus;
+    private Integer alarmType;
+    private Integer online;
+    private Integer limit;
+    private Integer offset;
+    private Integer version;
+    private String keyword;
+    private List sectionList;
+    private List<LampInfoDTO> list;
+    private Integer lightCount;
+    private Integer onlineCount;
+    private Integer alarmCount;
+    private Integer devTotal;
+    private Integer total;
+    private Integer total2;
+}

+ 27 - 0
src/main/java/com/welampiot/vo/LampPoleInfoVO.java

@@ -0,0 +1,27 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+@Data
+public class LampPoleInfoVO {
+    private Integer deviceCount;
+    private Integer runCount;
+    private Integer faultCount;
+    private Integer newCount;
+    private Integer disableCount;
+    private Integer dayCom;
+    private Integer monthCom;
+    private Integer totalCom;
+    private Integer lampCount;
+    private Integer videoCount;
+    private Integer weatherCount;
+    private Integer wifiCount;
+    private Integer screenCount;
+    private Integer loopCount;
+    private Integer radioCount;
+    private Integer emCount;
+    private Integer chargeCount;
+    private Integer lockCount;
+    private Integer tiltCount;
+    private Integer waterImmersionCount;
+}

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

@@ -0,0 +1,12 @@
+package com.welampiot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LampPoleVO {
+    private List sectionList; // 路段筛选
+    private Integer devType;
+    private Integer devId;
+}

+ 30 - 0
src/main/resources/config/lamp.yml

@@ -0,0 +1,30 @@
+lamp:
+  controlType: {0: 'WE-MA-10',
+                1: 'WE-MA-20',
+                2: 'WE-CON-10',
+                3: 'WE-CON-20',
+                4: 'WE-CON-P10',
+                5: 'WE-CON-4G20',
+                6: 'WE-CON-4G11',
+                7: 'WE-CON-4G10',
+                8: 'WE-CON-P20',
+                9: 'WE-CON-N20',
+                10: 'WE-CON-N10',
+                11: 'PGH-125-051A',
+                12: 'LHS-120-HP18G0',
+                13: 'SZ10-R1A-M',
+                14: 'PGH-060-046',
+                15: 'WE-MA-4G10',
+                16: 'WE-CON-ZB10',
+                17: 'WE-CON-R20',
+                18: 'WE-CON-R10',
+                19: 'WE-MA-N30',
+                20: 'WE-ZH-4GS',
+                21: 'WE-CON-4GH10',
+                22: 'WE-CON-4GH20',
+                23: 'WE-CON-4G15',
+                24: 'WE-CON-B10',
+                25: 'WE-CON-B20',
+                26: 'WE-CON-PW10',
+                27: 'WE-CON-PW20'
+  }

+ 12 - 1
src/main/resources/config/response.yml

@@ -1,6 +1,17 @@
 response:
   msgCN: {'0000': '操作成功',
-          '0001': '参数异常'}
+          '0001': '参数异常',
+          '0007': '缺少必要参数',
+          '0201': '请填写灯控编号',
+          '0202': '灯控编号只能包含数字跟字母',
+          '0203': '灯控编号重复',
+          '0204': '请填写灯控名称',
+          '0205': '灯控名称重复',
+          '0206': '请填写灯控设备地址',
+          '0207': '灯控设备地址重复',
+          '0208': '请选择区域',
+          '0209': '请选择路段',
+  }
   msgEN: { '0000': 'Operation successful',
            '0001': 'Parameter abnormality' }
   msgRU: { '0000': 'Операция прошла успешно',

+ 53 - 0
src/main/resources/mapper/GlobalLocationMapper.xml

@@ -18,6 +18,22 @@
         </choose>
     </select>
 
+    <select id="getListByPid" resultType="com.welampiot.dto.GlobalLocationDTO" parameterType="Integer">
+        select id,chinese_name chineseName
+        from global_location where pid = #{pid}
+    </select>
+
+    <select id="getListByPidList" resultType="com.welampiot.dto.GlobalLocationDTO" parameterType="java.util.List">
+        select id,chinese_name chineseName
+        from global_location where 1=1
+        <if test="pids != null and !pids.isEmpty()">
+            and pid in
+            <foreach item="vo" collection="pids" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+    </select>
+
     <select id="getAreaByLevelAndPid" resultType="com.welampiot.dto.GlobalLocationDTO" parameterType="Integer">
         <choose>
             <when test="version == 0">
@@ -34,4 +50,41 @@
             </otherwise>
         </choose>
     </select>
+
+    <select id="getUserProvinceNav" resultType="com.welampiot.dto.GlobalLocationDTO" parameterType="com.welampiot.vo.GlobalLocationVO">
+        select
+        <choose>
+            <when test="version == 1">
+                G.english_name as area,
+                b.english_name as name1,
+                c.english_name as name2,
+                d.english_name as name3,
+            </when>
+            <when test="version == 2">
+                b.ru_name as name1,
+                c.ru_name as name2,
+                d.ru_name as name3,
+            </when>
+            <otherwise>
+                b.chinese_name as name1,
+                c.chinese_name as name2,
+                d.chinese_name as name3,
+            </otherwise>
+        </choose>
+        b.level as level1,
+        c.level as level2,
+        d.level as level3,
+        b.id as id1,c.id as id2,d.id as id3
+        from section a
+        left join global_location b on a.pid = b.id
+        left join global_location c on b.pid = c.id
+        left join global_location d on c.pid = d.id
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            where a.id in
+            <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+        order by convert(b.chinese_name using gbk) ASC
+    </select>
 </mapper>

+ 7 - 0
src/main/resources/mapper/LampInfoLogMapper.xml

@@ -0,0 +1,7 @@
+<?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.LampInfoLogDao">
+    <delete id="deleteByLampId">
+        delete from lamp_info_log where lampid=#{lampId};
+    </delete>
+</mapper>

+ 287 - 20
src/main/resources/mapper/LampMapper.xml

@@ -2,25 +2,43 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.welampiot.dao.LampDao">
     <select id="getCountByVO" resultType="Integer" parameterType="com.welampiot.vo.LampCountVO">
-        select count(*) from lampinfo a left join network b on a.networkid = b.id
+        select count(*) from lampinfo L
+        left join section as S on S.id = L.sectionid
+        left join global_location as G on G.id = S.pid
+        left join lamp_info_log_new as LI on LI.lampid = L.id
+        left join network as N on N.id = L.networkid
+        left join net_card_info as CD on N.id = CD.net_id
+        left join policy as P on P.id = L.policyid
+        left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
         where 1=1
         <if test="sectionList != null and !sectionList.isEmpty()">
-            and a.sectionid in
+            and L.sectionid in
             <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
                 #{vo}
             </foreach>
         </if>
         <if test="onlineStatus != null">
-            and b.status = #{onlineStatus}
+            and N.status = #{onlineStatus}
         </if>
         <if test="lampStatus != null">
             <if test="lampStatus == 0">
-                and a.lighteness = 0
+                and L.lighteness = 0
             </if>
             <if test="lampStatus == 1">
-                and a.lighteness > 0
+                and L.lighteness > 0
+            </if>
+        </if>
+        <if test="alarmStatus != null">
+            <if test="alarmStatus == 0">
+                and (L.faultstatus = 0 or L.faultstatus = 128)
+            </if>
+            <if test="alarmStatus == 1">
+                and L.faultstatus != 0 and L.faultstatus != 128
             </if>
         </if>
+        <if test="keyword != null">
+            AND (L.number like '%#{keyword}%' OR L.address like '%#{keyword}%' OR L.macAddress like '%#{keyword}%')
+        </if>
     </select>
 
     <select id="getConsumptionByVO" resultType="Float" parameterType="com.welampiot.vo.LampCountVO">
@@ -49,25 +67,274 @@
                 #{vo}
             </foreach>
         </if>
+        <if test="startDate != null and startDate != ''">
+            and b.updatetime >= #{startDate}
+        </if>
     </select>
     <select id="getConsumptionListByVO" resultType="com.welampiot.vo.LampLogVO" parameterType="com.welampiot.vo.LampCountVO">
         select * from (
-            select sum(a.consum) as consumption,sum(a.powerSave) as powerSave,a.updatetime as updateTime
-            from lamp_info_cache_by_day a left join lampinfo b on b.id = a.lampid
-            where b.id is not null
-            <if test="sectionList != null and !sectionList.isEmpty()">
-                and a.sectionid in
-                <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
-                    #{vo}
-                </foreach>
-            </if>
-            <if test="startDate != null and startDate != ''">
-                and a.updatetime >= #{startDate}
+        select sum(a.consum) as consumption,sum(a.powerSave) as powerSave,a.updatetime as updateTime
+        from lamp_info_cache_by_day a left join lampinfo b on b.id = a.lampid
+        where b.id is not null
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and a.sectionid in
+            <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+        <if test="startDate != null and startDate != ''">
+            and a.updatetime >= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != ''">
+            and a.updatetime &lt;= #{endDate}
+        </if>
+        group by a.updatetime
+        ) as t order by t.updatetime asc
+    </select>
+
+    <select id="getListByVO" resultType="com.welampiot.dto.LampInfoDTO" parameterType="com.welampiot.vo.LampListResponseVO">
+        select
+        L.number,
+        L.id,
+        L.address as sn,
+        <choose>
+            <when test="version == 1">
+                G.english_name as area,
+            </when>
+            <when test="version == 2">
+                G.ru_name as area,
+            </when>
+            <otherwise>
+                G.chinese_name as area,
+            </otherwise>
+        </choose>
+        S.name as section,
+        S.timezone,
+        L.lighteness,
+        L.name,
+        LI.gridvolt as voltage,
+        LI.gridcurr as current,
+        LI.grid_active_power as power,
+        LI.work_time_total as lightTime,
+        LI.used_energy_total as totalEnergy,
+        LI.devicetime as cmdTime,
+        LI.led_lux_value,LI.leakage_cur,
+        N.status as networkStatus,
+        L.status as lampStatus,
+        L.online as lampOnline,
+        N.rssi,
+        N.snr,
+        N.protocoltype,
+        LI.updatetime as updateTime,
+        L.faultstatus,
+        L.mode,
+        N.hw_version as hwVersion,
+        N.sw_version as swVersion,
+        L.control_type as controlType,
+        L.macAddress,
+        L.dev_addr as devAddr,
+        L.bindStatus,
+        L.policy_type as policyType,
+        L.policyid,
+        L.longitude,
+        L.latitude,L.new_faultstatus,L.install_date,L.expiration_date,
+        P.name as policyName,AI.status as alarmStatus,AI.id as alarmid,AI.stralarmtype,
+        CD.dueDate,CD.workingCondition,CD.remainGprs,CD.useGprs,CD.totalGprs,CD.comboName,CD.comboType,CD.id as card_id
+        from lampinfo L
+        left join section as S on S.id = L.sectionid
+        left join global_location as G on G.id = S.pid
+        left join lamp_info_log_new as LI on LI.lampid = L.id
+        left join network as N on N.id = L.networkid
+        left join net_card_info as CD on N.id = CD.net_id
+        left join policy as P on P.id = L.policyid
+        left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and L.sectionid in
+            <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+        <if test="online != null">
+            AND ((N.status = #{online} and N.protocoltype != 5 and N.protocoltype != 11)  or (L.online = #{online}  and N.protocoltype = 5) or (L.online = #{online}  and N.protocoltype = 11 and L.control_type != 26 and L.control_type != 27) or (N.status = #{online}  and N.protocoltype = 11 and (L.control_type = 26 or L.control_type = 27)))
+        </if>
+        <if test="lightStatus != null">
+            <if test="lightStatus == 0">
+                AND ((N.status = 0 and N.protocoltype != 5) or (L.online = 0  and N.protocoltype = 5) or L.lighteness = 0)
             </if>
-            <if test="endDate != null and endDate != ''">
-                and a.updatetime &lt;= #{endDate}
+            <if test="lightStatus == 1">
+                AND ((N.status = 1 and N.protocoltype != 5)  or (L.online = 1  and N.protocoltype = 5)) and L.lighteness != 0
             </if>
-            group by a.updatetime
-        ) as t order by t.updatetime asc
+        </if>
+
+        <if test="keyword != null">
+            AND (L.number like '%#{keyword}%' OR L.address like '%#{keyword}%' OR L.macAddress like '%#{keyword}%')
+        </if>
+
+        <if test="alarmType != null">
+            AND AI.faultstatus = #{alarmType}
+        </if>
+
+        order by L.number asc,L.mode asc,L.createtime desc,L.id desc
+        <if test="offset != null and limit != null">
+            limit #{offset},#{limit}
+        </if>
+    </select>
+
+    <select id="getDetailsById" resultType="com.welampiot.dto.LampInfoDTO" parameterType="Integer">
+        select
+        L.number,
+        L.id,
+        L.address as sn,
+        <choose>
+            <when test="version == 1">
+                GL.english_name as area,
+            </when>
+            <when test="version == 2">
+                GL.ru_name as area,
+            </when>
+            <otherwise>
+                GL.chinese_name as area,
+            </otherwise>
+        </choose>
+        L.networkid as networkId,N.protocoltype as protocolType,L.areaid as areaId,
+        L.sectionid as sectionId,L.groupid as groupId,L.longitude,L.latitude,S.name as section,L.dev_addr as devAddr,
+        L.macAddress,L.section_id as loopNumber,G.name as `group`,N.network_name as network,N.rssi,
+        L.lamp_pole_id as lampPoleId,LP.name as lampPoleName,L.control_type as controlType,
+        L.lighteness,N.status as netStatus,LI.colour_value as colourValue,LI.used_energy_total as usedEnergyTotal,LI.updatetime,LI.work_time_total as workTimeTotal,
+        LI.gridPF,LI.used_energy_tonight as usedEnergyTonight,L.faultstatus,N.snr,N.rssi,AI.id as alarmId,
+        AI.stralarmtype as alarmInfo,S.timezone,L.status as lampStatas,L.freqId,
+        L.ratedpower as power,L.address as imei,N.simid,L.name,N.sw_version as solfVersion,
+        N.hw_version as hardVersion,L.install_date,L.expiration_date,L.mode
+        from lampinfo L
+        left join section as S on S.id = L.sectionid
+        left join global_location as GL on GL.id = S.pid
+        left join lamp_info_log_new as LI on LI.lampid = L.id
+        left join network as N on N.id = L.networkid
+        left join net_card_info as CD on N.id = CD.net_id
+        left join policy as P on P.id = L.policyid
+        left join lamp_pole as LP on LP.id = L.lamp_pole_id
+        left join `group` as G on G.id = L.groupid
+        left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
+        where L.id=#{id}
+    </select>
+
+    <select id="getDetailsByAddress" resultType="com.welampiot.dto.LampInfoDTO" parameterType="String">
+        select
+        L.number,
+        L.id,
+        L.address as sn,
+        <choose>
+            <when test="version == 1">
+                GL.english_name as area,
+            </when>
+            <when test="version == 2">
+                GL.ru_name as area,
+            </when>
+            <otherwise>
+                GL.chinese_name as area,
+            </otherwise>
+        </choose>
+        L.networkid as networkId,N.protocoltype as protocolType,L.areaid as areaId,
+        L.sectionid as sectionId,L.groupid as groupId,L.longitude,L.latitude,S.name as section,L.dev_addr as devAddr,
+        L.macAddress,L.section_id as loopNumber,G.name as `group`,N.network_name as network,N.rssi,
+        L.lamp_pole_id as lampPoleId,LP.name as lampPoleName,L.control_type as controlType,
+        L.lighteness,N.status as netStatus,LI.colour_value as colourValue,LI.used_energy_total as usedEnergyTotal,LI.updatetime,LI.work_time_total as workTimeTotal,
+        LI.gridPF,LI.used_energy_tonight as usedEnergyTonight,L.faultstatus,N.snr,N.rssi,AI.id as alarmId,
+        AI.stralarmtype as alarmInfo,S.timezone,L.status as lampStatas,L.freqId,
+        L.ratedpower as power,L.address as imei,N.simid,L.name,N.sw_version as solfVersion,
+        N.hw_version as hardVersion,L.install_date,L.expiration_date
+        from lampinfo L
+        left join section as S on S.id = L.sectionid
+        left join global_location as GL on GL.id = S.pid
+        left join lamp_info_log_new as LI on LI.lampid = L.id
+        left join network as N on N.id = L.networkid
+        left join net_card_info as CD on N.id = CD.net_id
+        left join policy as P on P.id = L.policyid
+        left join lamp_pole as LP on LP.id = L.lamp_pole_id
+        left join `group` as G on G.id = L.groupid
+        left join (select t1.* from all_alarm_info_log t1, (select lampid, max(updatetime) as maxtime from all_alarm_info_log group by lampid) t2 where t1.lampid = t2.lampid and t1.updatetime = t2.maxtime) as AI on L.id = AI.lampid
+        where L.address=#{address}
+    </select>
+
+    <select id="findByVO" resultType="Integer" parameterType="com.welampiot.dto.LampInfoDTO">
+        select count(*) from lampinfo L
+        where 1=1
+        <if test="sectionId != null">
+            and L.sectionid = #{sectionId}
+        </if>
+        <if test="name != null">
+            and L.name = #{name}
+        </if>
+        <if test="number != null">
+            and L.number = #{number}
+        </if>
+        <if test="sn != null">
+            and L.address = #{sn}
+        </if>
+        <if test="id != null">
+            and L.id != #{id}
+        </if>
     </select>
+    <select id="checkData" resultType="Integer" parameterType="com.welampiot.dto.LampInfoDTO">
+        select IFNULL(L.id,0) from lampinfo L
+        where 1=1
+        <if test="sectionId != null">
+            and L.sectionid = #{sectionId}
+        </if>
+        <if test="networkId != null">
+            and L.networkid != #{networkId}
+        </if>
+        <if test="name != null">
+            and L.name = #{name}
+        </if>
+        <if test="number != null">
+            and L.number = #{number}
+        </if>
+        <if test="sn != null">
+            and L.address = #{sn}
+        </if>
+        <if test="id != null">
+            and L.id != #{id}
+        </if>
+        limit 1
+    </select>
+    <insert id="add" parameterType="com.welampiot.dto.LampInfoDTO" useGeneratedKeys="true" keyProperty="id"
+    >
+        insert into lampinfo(networkid,name,number,address,areaid,sectionid,longitude,latitude,createtime,ratedpower,control_type
+        <if test="mode != null">
+            ,mode
+        </if>
+        )
+        values
+        (#{networkId},#{name},#{number},#{sn},#{areaId},#{sectionId},#{longitude},#{latitude},#{createTime},#{ratedPower},#{controlType}
+        <if test="mode != null">
+            ,#{mode}
+        </if>
+        )
+    </insert>
+    <update id="update" parameterType="com.welampiot.dto.LampInfoDTO"
+    >
+        update lampinfo
+        set
+        networkid=#{networkId},
+        name=#{name},
+        number=#{number},
+        address=#{sn},
+        areaid=#{areaId},
+        control_type=#{controlType},
+        sectionid=#{sectionId},
+        longitude=#{longitude},
+        latitude=#{latitude},
+        <if test="mode != null">
+            mode=#{mode},
+        </if>
+        ratedpower=#{ratedPower}
+
+        where id = #{id}
+    </update>
+
+    <delete id="deleteById">
+        delete from lampinfo where id=#{id};
+    </delete>
 </mapper>

+ 60 - 0
src/main/resources/mapper/LampPoleMapper.xml

@@ -11,4 +11,64 @@
             </foreach>
         </if>
     </select>
+
+    <select id="getNavByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
+        select LP.id,LP.name,LP.longitude,LP.latitude,W.online from lamp_pole LP
+        left join wifi as W on W.lamp_pole_id = LP.id
+        left join envmonitor as E on E.lamp_pole_id = LP.id
+        <if test="devType == 2">
+            left join video_monitor as V on V.lamp_pole_id = LP.id
+        </if>
+        <if test="devType == 1">
+            left join lampinfo as L on L.lamp_pole_id = LP.id
+        </if>
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and LP.sectionid in
+            <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+
+        <if test="devType != null">
+            <choose>
+                <when test="devType == 1">
+                    <if test="devId == null">
+                        AND (LP.devtype like "%0%")
+                    </if>
+                    <if test="devId != null">
+                        AND (LP.devtype like "%0%" OR L.id = #{devId})
+                    </if>
+                </when>
+                <when test="devType == 2">
+                    <if test="devId == null">
+                        AND (LP.devtype like "%1%")
+                    </if>
+                    <if test="devId != null">
+                        AND (LP.devtype like "%1%" OR L.id = #{devId})
+                    </if>
+                </when>
+                <otherwise>
+                    <if test="devId == null">
+                        AND (LP.devtype like "%7%")
+                    </if>
+                    <if test="devId != null">
+                        AND (LP.devtype like "%7%" OR L.id = #{devId})
+                    </if>
+                </otherwise>
+            </choose>
+        </if>
+
+    </select>
+
+    <select id="getListByVO" resultType="com.welampiot.dto.LampPoleDTO" parameterType="com.welampiot.vo.LampPoleVO">
+        select LP.id,LP.name,LP.devtype as devType,LP.createtime from lamp_pole LP
+        where 1=1
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and LP.sectionid in
+            <foreach item="vo" collection="sectionList" open="(" separator="," close=")">
+                #{vo}
+            </foreach>
+        </if>
+    </select>
 </mapper>

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

@@ -0,0 +1,27 @@
+<?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.NetworkDao">
+    <insert id="add" parameterType="com.welampiot.dto.NetworkDTO" useGeneratedKeys="true" keyProperty="id">
+        insert into network(network_name,devicesn,protocoltype,areaid,sectionid,createtime,net_type,gatewaytype,devicetype,userId)
+        values
+        (#{networkName},#{deviceSn},#{protocolType},#{areaId},#{sectionId},#{createTime},#{netType},#{gatewayType},#{deviceType},#{userId})
+<!--        <if test="sectionList != null and !sectionList.isEmpty()">-->
+<!--            where l.sectionid in-->
+<!--            <foreach item="dto" collection="sectionList" open="(" separator="," close=")">-->
+<!--                #{dto}-->
+<!--            </foreach>-->
+<!--        </if>-->
+    </insert>
+    <update id="update" parameterType="com.welampiot.dto.NetworkDTO">
+        update network
+        set
+        network_name=#{networkName},
+        devicesn=#{deviceSn},
+        protocoltype=#{protocolType},
+        areaid=#{areaId},
+        sectionid=#{sectionId},
+        devicetype=#{deviceType}
+
+        where id = #{id}
+    </update>
+</mapper>