|
@@ -0,0 +1,81 @@
|
|
|
+package com.welampiot.service.impl;
|
|
|
+
|
|
|
+import com.welampiot.dao.AirSwitchInfoDao;
|
|
|
+import com.welampiot.dto.AirSwitchInfoDTO;
|
|
|
+import com.welampiot.service.AirSwitchInfoService;
|
|
|
+import com.welampiot.vo.AirSwitchInfoReturnVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: AirSwitchInfoServiceImpl
|
|
|
+ * Package: com.welampiot.service.impl
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/3/28 - 21:27
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AirSwitchInfoServiceImpl implements AirSwitchInfoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AirSwitchInfoDao airSwitchInfoDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AirSwitchInfoReturnVO getAirSwitchInfo(Integer boxId, Integer online) {
|
|
|
+ AirSwitchInfoReturnVO airSwitchInfoReturnVO = new AirSwitchInfoReturnVO();
|
|
|
+ airSwitchInfoReturnVO.setTotalDev(airSwitchInfoDao.getCountByBoxId(boxId));
|
|
|
+ airSwitchInfoReturnVO.setOneDev(airSwitchInfoDao.getCountByBoxIdAndType(boxId,0));
|
|
|
+ airSwitchInfoReturnVO.setThreeDev(airSwitchInfoDao.getCountByBoxIdAndType(boxId,1));
|
|
|
+ airSwitchInfoReturnVO.setAlarmCount(airSwitchInfoDao.getCountByBoxIdAndAlarmStatus(boxId));
|
|
|
+ airSwitchInfoReturnVO.setPolicyId(airSwitchInfoDao.getPolicyIdByBoxId(boxId));
|
|
|
+ if (airSwitchInfoReturnVO.getPolicyId() != null && airSwitchInfoReturnVO.getPolicyId() != 0){
|
|
|
+ airSwitchInfoReturnVO.setPolicyName(airSwitchInfoDao.getPolicyNameByPolicyId(airSwitchInfoReturnVO.getPolicyId()));
|
|
|
+ }else {
|
|
|
+ airSwitchInfoReturnVO.setPolicyName("");
|
|
|
+ }
|
|
|
+ List<AirSwitchInfoDTO> airSwitchList = airSwitchInfoDao.getAirSwitchInfoByBoxId(boxId, online);
|
|
|
+ List<AirSwitchInfoDTO> airSwitchInfoDTOS = new ArrayList<>();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ airSwitchList.forEach(airSwitchInfoDTO -> {
|
|
|
+ if (airSwitchInfoDTO.getPolicyId() == null || airSwitchInfoDTO.getPolicyId() == 0){
|
|
|
+ airSwitchInfoDTO.setPolicyName("");
|
|
|
+ }
|
|
|
+ if (airSwitchInfoDTO.getLogTime() != null){
|
|
|
+ Date cmdTime;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(airSwitchInfoDTO.getLogTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //判断时区,为null默认东八区
|
|
|
+ long timezone = airSwitchInfoDTO.getTimezone() == null ? 8 : airSwitchInfoDTO.getTimezone();
|
|
|
+ long l = cmdTime.getTime() + timezone * 3600 * 1000;
|
|
|
+ cmdTime = new Date(l);
|
|
|
+ airSwitchInfoDTO.setLogTime(simpleDateFormat.format(cmdTime));
|
|
|
+ }else {
|
|
|
+ airSwitchInfoDTO.setLogTime("");
|
|
|
+ }
|
|
|
+ if (airSwitchInfoDTO.getStatus() != null && airSwitchInfoDTO.getStatus() == 1){
|
|
|
+ airSwitchInfoDTO.setStatus(1);
|
|
|
+ }else {
|
|
|
+ airSwitchInfoDTO.setStatus(0);
|
|
|
+ }
|
|
|
+ if (airSwitchInfoDTO.getType() != null && airSwitchInfoDTO.getType() == 1) {
|
|
|
+ airSwitchInfoDTO.setType(1);
|
|
|
+ }else {
|
|
|
+ airSwitchInfoDTO.setType(0);
|
|
|
+ }
|
|
|
+ airSwitchInfoDTOS.add(airSwitchInfoDTO);
|
|
|
+ });
|
|
|
+ airSwitchInfoReturnVO.setList(airSwitchInfoDTOS);
|
|
|
+ return airSwitchInfoReturnVO;
|
|
|
+ }
|
|
|
+}
|