|
@@ -1,14 +1,27 @@
|
|
|
package com.welampiot.service.impl;
|
|
|
|
|
|
+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.LampCountVO;
|
|
|
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.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class LampPoleServiceImpl implements LampPoleService {
|
|
@@ -26,4 +39,152 @@ public class LampPoleServiceImpl implements LampPoleService {
|
|
|
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;
|
|
|
+ @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();
|
|
|
+ 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());
|
|
|
+ lampPoleDTO.setInstallDate(lampPoleVO.getInstallDate());
|
|
|
+ lampPoleDTO.setExpirationDate(lampPoleVO.getExpirationDate());
|
|
|
+ lampPoleDao.add(lampPoleDTO);
|
|
|
+
|
|
|
+ Integer id = lampPoleDTO.getId();
|
|
|
+ // 添加云盒
|
|
|
+ Map cloudBox = lampPoleVO.getCloudBox();
|
|
|
+ WifiDTO wifiDTO = new WifiDTO();
|
|
|
+ wifiDTO.setLampPoleId(id);
|
|
|
+ if (cloudBox.containsKey("sn")) wifiDTO.setNum((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"));
|
|
|
+// if (wifiDTO.getSn() == null || wifiDTO.getSn().length() == 0) return toolUtils.response();
|
|
|
+ WifiDTO wifiDTO1 = new WifiDTO();
|
|
|
+ ArrayList<Integer> integers = new ArrayList<>();
|
|
|
+ integers.add(lampPoleVO.getSectionId());
|
|
|
+ wifiDTO1.setSectionList(integers);
|
|
|
+ wifiDTO1.setSn(wifiDTO.getSn());
|
|
|
+// if (wifiService.getCountByDTO(wifiDTO1).intValue() > 0) return toolUtils.response();
|
|
|
+ wifiService.add(wifiDTO);
|
|
|
+
|
|
|
+ // 添加灯控
|
|
|
+ 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) m.get("protocoltype"));
|
|
|
+ if (m.containsKey("controlType")) lampInfoDTO.setControlType((Integer) m.get("controlType"));
|
|
|
+ if (m.containsKey("ratedpower")) lampInfoDTO.setRatedPower((Integer) m.get("ratedpower"));
|
|
|
+ if (m.containsKey("installDate")) lampInfoDTO.setInstallDate( m.get("installDate").toString());
|
|
|
+ if (m.containsKey("expirationDate")) lampInfoDTO.setExpirationDate( m.get("expirationDate").toString());
|
|
|
+ BaseResult add = lampService.add(lampInfoDTO);
|
|
|
+ if (!add.getCode().equals("0000")) return add;
|
|
|
+ }
|
|
|
+
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,lampPoleVO.getVersion());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer update(LampPoleDTO lampPoleDTO) {
|
|
|
+ return lampPoleDao.update(lampPoleDTO);
|
|
|
+ }
|
|
|
}
|