123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- package com.welampiot.service.impl;
- import com.welampiot.dto.*;
- import com.welampiot.service.*;
- import com.welampiot.utils.VideoUtil;
- import com.welampiot.common.BaseResult;
- import com.welampiot.common.InterfaceResultEnum;
- import com.welampiot.dao.LampPoleDao;
- import com.welampiot.dto.LampInfoDTO;
- import com.welampiot.dto.LampPoleAlarmLogDTO;
- import com.welampiot.dto.LampPoleDTO;
- import com.welampiot.dto.WifiDTO;
- import com.welampiot.service.LampPoleAlarmLogService;
- import com.welampiot.service.LampPoleService;
- import com.welampiot.service.LampService;
- import com.welampiot.service.WifiService;
- import com.welampiot.utils.ToolUtils;
- import com.welampiot.vo.*;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- @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);
- }
- @Autowired
- private LampPoleAlarmLogService lampPoleAlarmLogService;
- @Autowired
- private ToolUtils toolUtils;
- @Autowired
- private LampService lampService;
- @Autowired
- private WifiService wifiService;
- @Autowired
- private VideoMonitorService videoMonitorService;
- @Autowired
- private VideoGbInfoService videoGbInfoService;
- @Override
- public List<LampPoleDTO> lampPoleList(LampPoleVO lampPoleVO) {
- List<LampPoleDTO> lampPoleDTOS = lampPoleDao.lampPoleList(lampPoleVO);
- ArrayList<LampPoleDTO> lampPoleDTOS1 = new ArrayList<>();
- ArrayList<Integer> lampPoleIds = new ArrayList<>();
- lampPoleIds.add(0);
- for (LampPoleDTO l :lampPoleDTOS){
- lampPoleIds.add(l.getId());
- }
- List<LampPoleAlarmLogDTO> listByLampPoleIdList = lampPoleAlarmLogService.getListByLampPoleIdList(lampPoleIds);
- HashMap<Integer, LampPoleAlarmLogDTO> integerLampPoleAlarmLogDTOHashMap = new HashMap<>();
- for (LampPoleAlarmLogDTO l :listByLampPoleIdList) {
- integerLampPoleAlarmLogDTOHashMap.put(l.getId(),l);
- }
- HashMap<Integer, String> integerStringHashMap = new HashMap<>();
- integerStringHashMap.put(1,"摄像头");
- integerStringHashMap.put(2,"WIFI");
- integerStringHashMap.put(3,"RFID");
- integerStringHashMap.put(4,"LED屏");
- integerStringHashMap.put(5,"一键报警");
- integerStringHashMap.put(6,"充电桩");
- integerStringHashMap.put(7,"气象站");
- integerStringHashMap.put(8,"微基站");
- integerStringHashMap.put(9,"音柱");
- integerStringHashMap.put(10,"云盒");
- for (LampPoleDTO l :lampPoleDTOS) {
- if (l.getIsInspec() == null) l.setIsInspec(0);
- if (l.getCity() != null){
- l.setLocation(l.getCity()+" "+l.getArea()+" "+l.getSection());
- }else {
- l.setLocation(l.getArea()+" "+l.getSection());
- }
- if (l.getPolicyName() == null) {
- if (lampPoleVO.getVersion() == 0){
- l.setPolicyName("暂无");
- } else if (lampPoleVO.getVersion() == 1) {
- l.setPolicyName("none");
- }
- }
- if (integerLampPoleAlarmLogDTOHashMap.containsKey(l.getId())){
- LampPoleAlarmLogDTO lampPoleAlarmLogDTO = integerLampPoleAlarmLogDTOHashMap.get(l.getId());
- if (integerStringHashMap.containsKey(lampPoleAlarmLogDTO.getDevType())){
- String s = integerStringHashMap.get(lampPoleAlarmLogDTO.getDevType());
- l.setFaultStatus(0);
- l.setAlarmInfo(s+"离线");
- }else {
- l.setFaultStatus(0);
- l.setAlarmInfo("");
- }
- }else {
- l.setFaultStatus(0);
- }
- lampPoleDTOS1.add(l);
- }
- return lampPoleDTOS1;
- }
- @Override
- public Integer lampPoleCount(LampPoleVO lampPoleVO) {
- return lampPoleDao.lampPoleCount(lampPoleVO);
- }
- @Override
- public BaseResult add(LampPoleVO lampPoleVO) {
- LampPoleDTO lampPoleDTO = new LampPoleDTO();
- lampPoleDTO.setCreateId(lampPoleVO.getCreateId());
- if (lampPoleVO.getAreaId() == null || lampPoleVO.getAreaId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getSectionId() == null || lampPoleVO.getSectionId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getName() == null || lampPoleVO.getName().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_NAME_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getNumber() == null || lampPoleVO.getNumber().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_POLE_NUMBER_ERROR,lampPoleVO.getVersion());
- if (!lampPoleVO.getNumber().matches("^[A-Za-z0-9_]+$")) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NUMBER_FORMAT_ERROR,lampPoleVO.getVersion());
- LampPoleCountVO lampPoleVO1 = new LampPoleCountVO();
- lampPoleVO1.setSectionId(lampPoleVO.getSectionId());
- lampPoleVO1.setName(lampPoleVO.getName());
- if (lampPoleDao.getCountByVO(lampPoleVO1).intValue() > 0) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NAME_UNIQUE_ERROR,lampPoleVO.getVersion());
- lampPoleVO1 = new LampPoleCountVO();
- lampPoleVO1.setSectionId(lampPoleVO.getSectionId());
- lampPoleVO1.setNumber(lampPoleVO.getNumber());
- if (lampPoleDao.getCountByVO(lampPoleVO1).intValue() > 0) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NUMBER_UNIQUE_ERROR,lampPoleVO.getVersion());
- lampPoleDTO.setName(lampPoleVO.getName());
- lampPoleDTO.setNumber(lampPoleVO.getNumber());
- lampPoleDTO.setAreaId(lampPoleVO.getAreaId());
- lampPoleDTO.setSectionId(lampPoleVO.getSectionId());
- lampPoleDTO.setHeight(lampPoleVO.getHeight() == null ? 0 : lampPoleVO.getHeight());
- lampPoleDTO.setLatitude(lampPoleVO.getLatitude().toString());
- lampPoleDTO.setLongitude(lampPoleVO.getLongitude().toString());
- lampPoleDTO.setInstallDate(lampPoleVO.getInstallDate());
- lampPoleDTO.setExpirationDate(lampPoleVO.getExpirationDate());
- Date endDate = new Date(System.currentTimeMillis());
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String createTime = simpleDateFormat.format(endDate).toString();
- lampPoleDTO.setCreateTime(createTime);
- lampPoleDao.add(lampPoleDTO);
- List<Integer> devType = new ArrayList<>();
- Integer id = lampPoleDTO.getId();
- // 添加云盒
- Map cloudBox = lampPoleVO.getCloudBox();
- WifiDTO wifiDTO = new WifiDTO();
- wifiDTO.setLampPoleId(id);
- wifiDTO.setVersion2(lampPoleVO.getVersion());
- if (cloudBox.containsKey("sn")) wifiDTO.setSn((String) cloudBox.get("sn"));
- if (cloudBox.containsKey("ipAddr")) wifiDTO.setIpAddr((String) cloudBox.get("ipAddr"));
- if (cloudBox.containsKey("model")) wifiDTO.setModel((Integer) cloudBox.get("model"));
- if (cloudBox.containsKey("remark1")) wifiDTO.setRemark1((String) cloudBox.get("remark1"));
- if (cloudBox.containsKey("remark2")) wifiDTO.setRemark2((String) cloudBox.get("remark2"));
- if (cloudBox.containsKey("remark3")) wifiDTO.setRemark3((String) cloudBox.get("remark3"));
- if (cloudBox.containsKey("remark4")) wifiDTO.setRemark4((String) cloudBox.get("remark4"));
- if (cloudBox.containsKey("remark5")) wifiDTO.setRemark5((String) cloudBox.get("remark5"));
- if (cloudBox.containsKey("remark6")) wifiDTO.setRemark6((String) cloudBox.get("remark6"));
- if (cloudBox.containsKey("installDate")) wifiDTO.setInstallDate((String) cloudBox.get("installDate"));
- if (cloudBox.containsKey("expirationDate")) wifiDTO.setExpirationDate((String) cloudBox.get("expirationDate"));
- BaseResult add1 = wifiService.add(wifiDTO);
- if (!add1.getCode().equals("0000")) return add1;
- devType.add(10);
- devType.add(2);
- // 添加灯控
- List<Map> lightDevList = lampPoleVO.getLightDevList();
- LampInfoDTO lampInfoDTO;
- for (Map m :lightDevList) {
- lampInfoDTO = new LampInfoDTO();
- if (m.containsKey("address")) lampInfoDTO.setSn(m.get("address").toString());
- if (m.containsKey("number")) lampInfoDTO.setNumber(m.get("number").toString());
- if (m.containsKey("name")) lampInfoDTO.setName(m.get("name").toString());
- if (m.containsKey("protocolType")) lampInfoDTO.setProtocolType(Integer.parseInt((String) m.get("protocolType")));
- if (m.containsKey("controlType")) lampInfoDTO.setControlType(Integer.parseInt((String) m.get("controlType")));
- if (m.containsKey("ratedPower")) {
- if ( m.get("ratedPower") == null || m.get("ratedPower").toString().length() == 0){
- lampInfoDTO.setRatedPower(0);
- }else {
- lampInfoDTO.setRatedPower(Integer.parseInt((String) m.get("ratedPower")));
- }
- }
- if (m.containsKey("installDate")) lampInfoDTO.setInstallDate( m.get("installDate").toString());
- if (m.containsKey("expirationDate")) lampInfoDTO.setExpirationDate( m.get("expirationDate").toString());
- lampInfoDTO.setCreateTime(createTime);
- lampInfoDTO.setVersion(lampPoleVO.getVersion());
- lampInfoDTO.setAreaId(lampPoleVO.getAreaId());
- lampInfoDTO.setSectionId(lampPoleVO.getSectionId());
- lampInfoDTO.setLatitude(lampPoleVO.getLatitude());
- lampInfoDTO.setLongitude(lampPoleVO.getLongitude());
- lampInfoDTO.setLampPoleId(id);
- BaseResult add = lampService.add(lampInfoDTO);
- if (!add.getCode().equals("0000")) return add;
- }
- devType.add(0);
- // 添加摄像头
- // 设备类型(0 路灯,2 WIFI,3 RFID,4 LED屏,5 一键报警,6 充电桩,7 气象站,8 微基站,9 广播音柱,10 云盒,11 电缆,12 太阳能板凳,13 超级电源,14 水浸传感器,15 智能门锁,16 储能逆变,17 噪声监控,18 倾斜监测,19 液位传感器,20 灯带)多种类型用逗号隔开
- List<Map> videoList = lampPoleVO.getVideoList();
- if (videoList != null && !videoList.isEmpty()){
- for (Map m :videoList) {
- VideoMonitorDTO videoMonitorDTO = new VideoMonitorDTO();
- if (m.containsKey("id")) videoMonitorDTO.setId((Integer) m.get("id"));
- if (m.containsKey("name")) {
- videoMonitorDTO.setName((String) m.get("name"));
- }else {
- }
- if (m.containsKey("devId")) videoMonitorDTO.setDevId((String) m.get("devId"));
- if (m.containsKey("password")) videoMonitorDTO.setPassword((String) m.get("password"));
- if (m.containsKey("channel")) videoMonitorDTO.setChannel((String) m.get("channel"));
- if (m.containsKey("faceImage")) videoMonitorDTO.setFaceImage((String) m.get("faceImage"));
- if (m.containsKey("deviceType")) videoMonitorDTO.setDeviceType((Integer) m.get("deviceType"));
- if (m.containsKey("netType")) videoMonitorDTO.setNetType((Integer) m.get("netType"));
- if (m.containsKey("ipAddr")) videoMonitorDTO.setIpAddr((String) m.get("ipAddr"));
- if (m.containsKey("devPwd")) videoMonitorDTO.setDevPwd((String) m.get("devPwd"));
- if (m.containsKey("installDate")) videoMonitorDTO.setInstallDate((String) m.get("installDate"));
- if (m.containsKey("expirationDate")) videoMonitorDTO.setExpirationDate((String) m.get("expirationDate"));
- if (m.containsKey("type")) videoMonitorDTO.setType((Integer) m.get("type"));
- String gbAddressByDevId = VideoUtil.getGbAddressByDevId(videoMonitorDTO.getDevId(), videoGbInfoService);
- videoMonitorDTO.setGbAddress(gbAddressByDevId);
- if (m.containsKey("id")){
- videoMonitorService.updateVideoMonitorData(videoMonitorDTO);
- }else {
- videoMonitorService.addVideoMonitorData(videoMonitorDTO);
- }
- }
- devType.add(1);
- }
- // 添加气象站
- if (lampPoleVO.getWeatherDev() != null){
- Map weatherDev = lampPoleVO.getWeatherDev();
- EnvmonitorDTO envmonitorDTO = new EnvmonitorDTO();
- if (weatherDev.containsKey("model")) envmonitorDTO.setModel(String.valueOf(weatherDev.get("model")));
- if (weatherDev.containsKey("address")) envmonitorDTO.setAddress(String.valueOf(weatherDev.get("address")));
- if (weatherDev.containsKey("devType")) envmonitorDTO.setDevType((Integer) weatherDev.get("devType"));
- if (weatherDev.containsKey("pramType")) envmonitorDTO.setPramType((Integer) weatherDev.get("pramType"));
- if (weatherDev.containsKey("rate")) envmonitorDTO.setRate((Integer) weatherDev.get("rate"));
- if (weatherDev.containsKey("netType")) envmonitorDTO.setNetType((Integer) weatherDev.get("netType"));
- if (weatherDev.containsKey("serialPort")) envmonitorDTO.setSerialPort((Integer) weatherDev.get("serialPort"));
- if (weatherDev.containsKey("mp")) envmonitorDTO.setMp((Integer) weatherDev.get("mp"));
- if (weatherDev.containsKey("devList")){
- Object devList = weatherDev.get("devList");
- System.out.println(devList);
- }
- }
- LampPoleDTO lampPoleDTO1 = new LampPoleDTO();
- lampPoleDTO1.setId(lampPoleDTO.getId());
- lampPoleDTO1.setDevType(StringUtils.join(devType,","));
- lampPoleDTO1.setSn(wifiDTO.getSn());
- lampPoleDao.update(lampPoleDTO1);
- // return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampPoleVO.getVersion());
- return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,lampPoleVO.getVersion());
- }
- @Override
- public BaseResult update(LampPoleVO lampPoleVO) {
- LampPoleDTO lampPoleDTO = new LampPoleDTO();
- lampPoleDTO.setId(lampPoleVO.getId());
- if (lampPoleVO.getAreaId() == null || lampPoleVO.getAreaId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getSectionId() == null || lampPoleVO.getSectionId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getName() == null || lampPoleVO.getName().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_NAME_ERROR,lampPoleVO.getVersion());
- if (lampPoleVO.getNumber() == null || lampPoleVO.getNumber().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_LAMP_POLE_NUMBER_ERROR,lampPoleVO.getVersion());
- if (!lampPoleVO.getNumber().matches("^[A-Za-z0-9_]+$")) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NUMBER_FORMAT_ERROR,lampPoleVO.getVersion());
- LampPoleCountVO lampPoleVO1 = new LampPoleCountVO();
- lampPoleVO1.setId(lampPoleDTO.getId());
- lampPoleVO1.setSectionId(lampPoleVO.getSectionId());
- lampPoleVO1.setName(lampPoleVO.getName());
- if (lampPoleDao.getCountByVO(lampPoleVO1).intValue() > 0) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NAME_UNIQUE_ERROR,lampPoleVO.getVersion());
- lampPoleVO1 = new LampPoleCountVO();
- lampPoleVO1.setId(lampPoleDTO.getId());
- lampPoleVO1.setSectionId(lampPoleVO.getSectionId());
- lampPoleVO1.setNumber(lampPoleVO.getNumber());
- if (lampPoleDao.getCountByVO(lampPoleVO1).intValue() > 0) return toolUtils.response(InterfaceResultEnum.LAMP_POLE_NUMBER_UNIQUE_ERROR,lampPoleVO.getVersion());
- lampPoleDTO.setName(lampPoleVO.getName());
- lampPoleDTO.setNumber(lampPoleVO.getNumber());
- lampPoleDTO.setAreaId(lampPoleVO.getAreaId());
- lampPoleDTO.setSectionId(lampPoleVO.getSectionId());
- lampPoleDTO.setHeight(lampPoleVO.getHeight() == null ? 0 : lampPoleVO.getHeight());
- lampPoleDTO.setLatitude(lampPoleVO.getLatitude().toString());
- lampPoleDTO.setLongitude(lampPoleVO.getLongitude().toString());
- lampPoleDTO.setInstallDate(lampPoleVO.getInstallDate());
- lampPoleDTO.setExpirationDate(lampPoleVO.getExpirationDate());
- lampPoleDao.update(lampPoleDTO);
- Map cloudBox = lampPoleVO.getCloudBox();
- WifiDTO wifiDTO = new WifiDTO();
- wifiDTO.setLampPoleId(lampPoleDTO.getId());
- wifiDTO.setVersion2(lampPoleVO.getVersion());
- if (cloudBox.containsKey("sn")) wifiDTO.setSn((String) cloudBox.get("sn"));
- if (cloudBox.containsKey("ipAddr")) wifiDTO.setIpAddr((String) cloudBox.get("ipAddr"));
- if (cloudBox.containsKey("model")) wifiDTO.setModel((Integer) cloudBox.get("model"));
- if (cloudBox.containsKey("remark1")) wifiDTO.setRemark1((String) cloudBox.get("remark1"));
- if (cloudBox.containsKey("remark2")) wifiDTO.setRemark2((String) cloudBox.get("remark2"));
- if (cloudBox.containsKey("remark3")) wifiDTO.setRemark3((String) cloudBox.get("remark3"));
- if (cloudBox.containsKey("remark4")) wifiDTO.setRemark4((String) cloudBox.get("remark4"));
- if (cloudBox.containsKey("remark5")) wifiDTO.setRemark5((String) cloudBox.get("remark5"));
- if (cloudBox.containsKey("remark6")) wifiDTO.setRemark6((String) cloudBox.get("remark6"));
- if (cloudBox.containsKey("installDate")) wifiDTO.setInstallDate((String) cloudBox.get("installDate"));
- if (cloudBox.containsKey("expirationDate")) wifiDTO.setExpirationDate((String) cloudBox.get("expirationDate"));
- BaseResult add1 = wifiService.update(wifiDTO);
- if (!add1.getCode().equals("0000")) return add1;
- // 添加灯控
- Date endDate = new Date(System.currentTimeMillis());
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String createTime = simpleDateFormat.format(endDate).toString();
- List<Map> lightDevList = lampPoleVO.getLightDevList();
- LampInfoDTO lampInfoDTO;
- for (Map m :lightDevList) {
- lampInfoDTO = new LampInfoDTO();
- if (m.containsKey("address")) lampInfoDTO.setSn(m.get("address").toString());
- if (m.containsKey("number")) lampInfoDTO.setNumber(m.get("number").toString());
- if (m.containsKey("name")) lampInfoDTO.setName(m.get("name").toString());
- if (m.containsKey("protocolType")) lampInfoDTO.setProtocolType(Integer.parseInt((String) m.get("protocolType")));
- if (m.containsKey("controlType")) lampInfoDTO.setControlType(Integer.parseInt((String) m.get("controlType")));
- if (m.containsKey("ratedPower")) {
- if ( m.get("ratedPower") == null || m.get("ratedPower").toString().length() == 0){
- lampInfoDTO.setRatedPower(0);
- }else {
- lampInfoDTO.setRatedPower(Integer.parseInt((String) m.get("ratedPower")));
- }
- }
- if (m.containsKey("installDate")) lampInfoDTO.setInstallDate( m.get("installDate").toString());
- if (m.containsKey("expirationDate")) lampInfoDTO.setExpirationDate( m.get("expirationDate").toString());
- if (m.containsKey("id") && m.get("id") != null && m.get("id").toString().length() != 0) lampInfoDTO.setId(Integer.parseInt((String) m.get("id")));
- lampInfoDTO.setVersion(lampPoleVO.getVersion());
- lampInfoDTO.setAreaId(lampPoleVO.getAreaId());
- lampInfoDTO.setSectionId(lampPoleVO.getSectionId());
- lampInfoDTO.setLatitude(lampPoleVO.getLatitude());
- lampInfoDTO.setLongitude(lampPoleVO.getLongitude());
- lampInfoDTO.setLampPoleId(lampPoleVO.getId());
- BaseResult add;
- if (lampInfoDTO.getId() != null && lampInfoDTO.getId() != 0){
- add = lampService.update(lampInfoDTO);
- }else {
- lampInfoDTO.setCreateTime(createTime);
- add = lampService.add(lampInfoDTO);
- }
- if (!add.getCode().equals("0000")) return add;
- }
- return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampPoleVO.getVersion());
- }
- @Override
- public LampPoleDTO getDetailById(Integer id) {
- return lampPoleDao.getDetailById(id);
- }
- @Override
- public Integer deleteById(Integer id) {
- if (id == null) return null;
- // 删除灯控
- LampListResponseVO lampListResponseVO = new LampListResponseVO();
- lampListResponseVO.setLampPoleId(id);
- List<LampInfoDTO> listByVO = lampService.getListByVO(lampListResponseVO);
- for (LampInfoDTO l :listByVO) {
- if (l.getId() != null) lampService.deleteById(l.getId());
- }
- // 删除云盒
- WifiDTO wifiDTO = new WifiDTO();
- wifiDTO.setLampPoleId(id);
- List<WifiDTO> wifiList = wifiService.getWifiListByDTO(wifiDTO);
- for (WifiDTO w :wifiList) {
- if (w.getId() != null) wifiService.deleteById(w.getId());
- }
- return lampPoleDao.deleteById(id);
- }
- @Override
- public LampPoleVO getLampPoleListByDTO(LampPoleDTO dto) {
- LampPoleVO lampPoleVO = new LampPoleVO();
- List<LampPoleDTO> lampPoleList = lampPoleDao.getLampPoleListByDTO(dto);
- List<LampPoleDTO> list = new ArrayList<>();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- lampPoleList.forEach(lampDTO -> {
- //设备状态(0 = 设备正常, 1 = 供电异常,2 = 灯闪,4 =灯坏, 8 = LED驱动故障, 16 = 数据同步失败)
- if (lampDTO.getFaultStatus() != null && lampDTO.getFaultStatus() == 16) {
- lampDTO.setAlarmStatusStr("数据同步失败");
- } else if (lampDTO.getFaultStatus() != null && lampDTO.getFaultStatus() == 8) {
- lampDTO.setAlarmStatusStr("LED驱动故障");
- } else if (lampDTO.getFaultStatus() != null && lampDTO.getFaultStatus() == 4) {
- lampDTO.setAlarmStatusStr("灯坏");
- } else if (lampDTO.getFaultStatus() != null && lampDTO.getFaultStatus() == 2) {
- lampDTO.setAlarmStatusStr("灯闪");
- } else if (lampDTO.getFaultStatus() != null && lampDTO.getFaultStatus() == 1) {
- lampDTO.setAlarmStatusStr("供电异常");
- } else {
- lampDTO.setAlarmStatusStr("设备正常");
- }
- if (lampDTO.getArea() == null) {
- lampDTO.setArea("");
- }
- if (lampDTO.getSection() == null) {
- lampDTO.setSection("");
- }
- if (lampDTO.getUpdateTime() != null && !lampDTO.getUpdateTime().equals("")) {
- Date cmdTime;
- try {
- cmdTime = simpleDateFormat.parse(lampDTO.getUpdateTime());
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- //判断时区,为null默认东八区
- long timezone = lampDTO.getTimezone() == null ? 8 : lampDTO.getTimezone();
- long l = cmdTime.getTime() + timezone * 3600 * 1000;
- cmdTime = new Date(l);
- lampDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
- } else {
- lampDTO.setUpdateTime("");
- }
- if (lampDTO.getVideoId() == null) {
- lampDTO.setVideoId(0);
- }
- list.add(lampDTO);
- });
- lampPoleVO.setList(list);
- return lampPoleVO;
- }
- @Override
- public LampPoleInfoVO getLampPoleCount(LampPoleDTO lampPoleDTO, LampInfoDTO lampInfoDTO) {
- LampPoleInfoVO countVO = new LampPoleInfoVO();
- countVO.setInstallCount(lampPoleDao.getLampPoleInstallTotalByDTO(lampPoleDTO));
- countVO.setOnlineCount(lampService.getLampOnlineTotalByDTO(lampInfoDTO));
- countVO.setFaultCount(lampService.getLampFaultTotalByDTO(lampInfoDTO));
- countVO.setLightingCount(lampService.getLampLightTotalByDTO(lampInfoDTO));
- countVO.setChargeCount(lampPoleDao.getChargeCount(lampPoleDTO));
- countVO.setVideoCount(lampPoleDao.getVideoCount(lampPoleDTO));
- countVO.setScreenCount(lampPoleDao.getScreenCount(lampPoleDTO));
- countVO.setWifiCount(lampPoleDao.getWifiCount(lampPoleDTO));
- countVO.setWeatherCount(lampPoleDao.getWeatherCount(lampPoleDTO));
- countVO.setEmCount(lampPoleDao.getEmergencyCount(lampPoleDTO));
- countVO.setRfidCount(lampPoleDao.getRfidCount(lampPoleDTO));
- countVO.setRadioCount(lampPoleDao.getBroadcastCount(lampPoleDTO));
- return countVO;
- }
- @Override
- public Integer getSectionIdByLampPoleId(Integer id) {
- return lampPoleDao.getSectionIdByLampPoleId(id);
- }
- @Override
- public void changeLampPoleLocationById(LampPoleDTO dto) {
- lampPoleDao.changeLampPoleLocationById(dto);
- }
- @Override
- public LampPoleDTO getLampPoleDTOById(Integer id) {
- return lampPoleDao.getLampPoleDTOById(id);
- }
- @Override
- public Integer getLampPoleAlarmTotal(LampPoleVO vo) {
- return lampPoleDao.getLampPoleAlarmTotal(vo);
- }
- @Override
- public Integer getLampPoleAlarmStatusTotal(LampPoleVO vo) {
- return lampPoleDao.getLampPoleAlarmStatusTotal(vo);
- }
- @Override
- public Integer getLampPoleOfDevAlarmTotal(LampPoleVO vo) {
- return lampPoleDao.getLampPoleOfDevAlarmTotal(vo);
- }
- @Override
- public List<LampPoleDTO> getAlarmLampPoleList(LampPoleVO vo) {
- return lampPoleDao.getAlarmLampPoleList(vo);
- }
- @Override
- public Integer getLampPoleLightCount(LampPoleVO vo) {
- return lampPoleDao.getLampPoleLightCount(vo);
- }
- @Override
- public List<LampPoleDTO> getLampPoleLightList(LampPoleVO vo) {
- return lampPoleDao.getLampPoleLightList(vo);
- }
- @Override
- public Integer getNewCreateLampPoleCount(LampPoleVO vo) {
- return lampPoleDao.getNewCreateLampPoleCount(vo);
- }
- @Override
- public Integer getLampPoleInstallTotal(LampPoleVO vo) {
- return lampPoleDao.getLampPoleInstallTotal(vo);
- }
- @Override
- public List<LampPoleDTO> getLampPoleInstallList(LampPoleVO vo) {
- return lampPoleDao.getLampPoleInstallList(vo);
- }
- @Override
- public void updateLampPoleDevType(LampPoleDTO dto) {
- lampPoleDao.updateLampPoleDevType(dto);
- }
- @Override
- public List<LampPoleDTO> getSectionLampPoleList(LampPoleVO vo) {
- return lampPoleDao.getSectionLampPoleList(vo);
- }
- @Override
- public List<LampPoleDTO> getLampPoleByLampIds(List<String> lampIds) {
- return lampPoleDao.getLampPoleByLampIds(lampIds);
- }
- @Override
- public void updateLampPoleIcon(LampPoleDTO dto) {
- lampPoleDao.updateLampPoleIcon(dto);
- }
- @Override
- public List<LampPoleDTO> getNewLampPoleList2(LampPoleVO vo) {
- return lampPoleDao.getNewLampPoleList2(vo);
- }
- @Override
- public List<LampPoleDTO> getNewLampPoleList3(LampPoleVO vo) {
- return lampPoleDao.getNewLampPoleList3(vo);
- }
- @Override
- public LampPoleDTO getLampPoleDetails(LampPoleVO vo) {
- return lampPoleDao.getLampPoleDetails(vo);
- }
- @Override
- public LampInfoLogNewDTO getComBySectionList(LampPoleVO lampPoleVO) {
- return lampPoleDao.getComBySectionList(lampPoleVO);
- }
- @Override
- public List<LampPoleDTO> getLampPoleDevList(LampPoleVO vo) {
- return lampPoleDao.getLampPoleDevList(vo);
- }
- @Override
- public List<LampPoleDTO> getLampPoleAlarmInfoList(LampPoleVO vo) {
- return lampPoleDao.getLampPoleAlarmInfoList(vo);
- }
- @Override
- public LampPoleInfoVO getLampPoleDevCount(LampPoleDTO dto) {
- LampPoleInfoVO lampPoleInfoVO = new LampPoleInfoVO();
- lampPoleInfoVO.setWifiCount(lampPoleDao.getWifiCount(dto));
- lampPoleInfoVO.setBroadcastCount(lampPoleDao.getBroadcastCount(dto));
- lampPoleInfoVO.setLampCount(lampPoleDao.getLampInfoCount(dto));
- lampPoleInfoVO.setLoopCount(lampPoleDao.getLoopCount(dto));
- lampPoleInfoVO.setVideoCount(lampPoleDao.getVideoCount(dto));
- lampPoleInfoVO.setChargeCount(lampPoleDao.getChargeCount(dto));
- lampPoleInfoVO.setLedCount(lampPoleDao.getScreenCount(dto));
- lampPoleInfoVO.setWellCoverCount(lampPoleDao.getManholeCount(dto));
- lampPoleInfoVO.setWeatherCount(lampPoleDao.getWeatherCount(dto));
- lampPoleInfoVO.setTrashCount(lampPoleDao.getTrashCount(dto));
- lampPoleInfoVO.setOneKeyCount(lampPoleDao.getEmergencyCount(dto));
- lampPoleInfoVO.setLineCount(0);
- return lampPoleInfoVO;
- }
- @Override
- public List<LampPoleDTO> getLampPoleAlarmListByLampPoleId(Integer lampPoleId) {
- return lampPoleDao.getLampPoleAlarmListByLampPoleId(lampPoleId);
- }
- @Override
- public LampPoleDTO getNewLampPoleDetailsById(Integer id) {
- return lampPoleDao.getNewLampPoleDetailsById(id);
- }
- @Override
- public List<LampPoleDTO> getLampListByLampPoleId(Integer lampPoleId) {
- return lampPoleDao.getLampListByLampPoleId(lampPoleId);
- }
- @Override
- public LampPoleInfoVO getLampPoleBigScreenCount(LampPoleDTO lampPoleDTO, LampInfoDTO lampInfoDTO) {
- LampPoleInfoVO countVO = new LampPoleInfoVO();
- Integer total = lampPoleDao.getLampPoleInstallTotalByDTO(lampPoleDTO);
- countVO.setInstallCount(total);
- countVO.setLampPoleCount(total);
- countVO.setOnlineCount(lampService.getLampOnlineTotalByDTO(lampInfoDTO));
- countVO.setFaultCount(lampService.getLampFaultTotalByDTO(lampInfoDTO));
- countVO.setLightCount(lampService.getLampLightTotalByDTO(lampInfoDTO));
- countVO.setScreenCount(lampPoleDao.getScreenCount(lampPoleDTO));
- return countVO;
- }
- @Override
- public List<LampPoleDTO> getMapDataByVO(MapDataVO vo) {
- return lampPoleDao.getMapDataByVO(vo);
- }
- @Override
- public Integer getAlarmCountByVO(LampPoleCountVO lampPoleCountVO) {
- return lampPoleDao.getAlarmCountByVO(lampPoleCountVO);
- }
- @Override
- public void updateById(LampPoleDTO lampPoleDTO){
- lampPoleDao.updateById( lampPoleDTO);
- }
- @Override
- public List<LampPoleDTO>getPoleAlarmLogList(List<Integer> lampPoleIds){
- return lampPoleDao.getPoleAlarmLogList(lampPoleIds);
- }
- @Override
- public LampPoleDTO getLocalDataById(Integer id){
- return lampPoleDao.getLocalDataById(id);
- }
- @Override
- public List<LampPoleDTO> getRangeLampPole(HashMap<String,Double> hashMap){
- return lampPoleDao.getRangeLampPole(hashMap);
- }
- @Override
- public LampPoleDTO getSimpleOne(LampPoleDTO dto){
- return lampPoleDao.getSimpleOne(dto);
- }
- }
|