package com.welampiot.service.impl; import com.welampiot.dao.BroadcastDao; import com.welampiot.dto.BroadcastDTO; import com.welampiot.dto.BroadcastItemDTO; import com.welampiot.dto.BroadcastProListDTO; import com.welampiot.service.BroadcastService; import com.welampiot.vo.BroadcastItemVO; import com.welampiot.vo.BroadcastProListVO; 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.List; /** * ClassName: BroadcastServiceImpl * Package: com.welampiot.service.impl * Description: * * @Author: zhj_Start * @Create: 2023/4/17 - 11:19 * @Version: v1.0 */ @Service public class BroadcastServiceImpl implements BroadcastService { @Autowired private BroadcastDao broadcastDao; @Override public List getDevListByBroadcastDTO(BroadcastDTO dto) { return broadcastDao.getDevListByBroadcastDTO(dto); // BroadcastVO vo = new BroadcastVO(); // vo.setTotal(broadcastDao.getTotalBySectionList(dto)); // vo.setOnlineTotal(broadcastDao.getOnlineTotalBySectionList(dto)); // List devList = broadcastDao.getDevListByBroadcastDTO(dto); // List list = new ArrayList<>(); // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // devList.forEach(broadcastDTO ->{ // if (broadcastDTO.getOnline() != null && broadcastDTO.getOnline() == 1){ // broadcastDTO.setOnline(1); // }else { // broadcastDTO.setOnline(0); // } // if (broadcastDTO.getProName() == null){ // broadcastDTO.setProName(""); // } // if (broadcastDTO.getLampPoleName() == null){ // broadcastDTO.setLampPoleName(""); // } // if (broadcastDTO.getType() != null && broadcastDTO.getType() == 1){ // broadcastDTO.setType(1); // }else { // broadcastDTO.setType(0); // } // if (broadcastDTO.getIsPlay() != null && broadcastDTO.getIsPlay() == 1){ // broadcastDTO.setIsPlay(1); // }else { // broadcastDTO.setIsPlay(0); // } // if (broadcastDTO.getInstallDate() != null && !broadcastDTO.getInstallDate().equals("")){ // try { // broadcastDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getInstallDate()))); // } catch (ParseException e) { // throw new RuntimeException(e); // } // }else { // broadcastDTO.setInstallDate(""); // } // if (broadcastDTO.getExpirationDate() != null && !broadcastDTO.getExpirationDate().equals("")){ // try { // broadcastDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getExpirationDate()))); // } catch (ParseException e) { // throw new RuntimeException(e); // } // }else { // broadcastDTO.setExpirationDate(""); // } // list.add(broadcastDTO); // }); // vo.setList(list); // return vo; } @Override public BroadcastProListVO getProListByDTO(String username) { BroadcastProListVO vo = new BroadcastProListVO(); Integer userId = broadcastDao.getUserIdByUserName(username); List proList = broadcastDao.getProListByDTO(userId); vo.setList(proList); return vo; } @Override public BroadcastItemVO getItemListByDTO(String username, Integer devId) { BroadcastItemVO vo = new BroadcastItemVO(); Integer userId = broadcastDao.getUserIdByUserName(username); List itemList = broadcastDao.getItemListByDTO(userId, devId); List list = new ArrayList<>(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); itemList.forEach(broadcastItemDTO -> { if (broadcastItemDTO.getBroadcastStr() == null){ broadcastItemDTO.setBroadcastStr(""); } if (broadcastItemDTO.getProType() != null && broadcastItemDTO.getProType() == 1){ broadcastItemDTO.setProType(1); }else { broadcastItemDTO.setProType(0); } if (broadcastItemDTO.getStatus() != null && broadcastItemDTO.getStatus() == 1){ broadcastItemDTO.setStatus(1); }else { broadcastItemDTO.setStatus(0); } if (broadcastItemDTO.getCreateTime() != null && !broadcastItemDTO.getCreateTime().equals("")){ try { broadcastItemDTO.setCreateTime(simpleDateFormat.format(simpleDateFormat.parse(broadcastItemDTO.getCreateTime()))); } catch (ParseException e) { throw new RuntimeException(e); } }else { broadcastItemDTO.setCreateTime(""); } list.add(broadcastItemDTO); }); vo.setList(list); return vo; } @Override public void deleteBroadcastById(Integer id) { broadcastDao.deleteBroadcastById(id); } @Override public BroadcastDTO getBroadcastById(Integer id) { return broadcastDao.getBroadcastById(id); } @Override public Integer getBroadcastCountByLampPoleId(Integer lampPoleId) { return broadcastDao.getBroadcastCountByLampPoleId(lampPoleId); } @Override public BroadcastDTO getBroadcastDTOByLampPoleId(Integer lampPoleId) { return broadcastDao.getBroadcastDTOByLampPoleId(lampPoleId); } @Override public void updateLampPoleBroadcastData(BroadcastDTO dto) { broadcastDao.updateLampPoleBroadcastData(dto); } @Override public Integer checkBroadcastData(BroadcastDTO dto) { return broadcastDao.checkBroadcastData(dto); } @Override public void updateBroadcastById(BroadcastDTO dto) { broadcastDao.updateBroadcastById(dto); } @Override public List getListByIds(String ids) { return broadcastDao.getListByIds(ids); } @Override public Integer getTotalBySectionList(BroadcastDTO dto) { return broadcastDao.getTotalBySectionList(dto); } @Override public BroadcastDTO getOneDataByLampPoleId(Integer lampPoleId){ return broadcastDao.getOneDataByLampPoleId(lampPoleId); } @Override public BroadcastDTO getData(Integer lampPoleId){ return broadcastDao.getData(lampPoleId); } @Override public Integer getCount(BroadcastDTO dto){ return broadcastDao.getCount(dto); } @Override public List getList(BroadcastDTO dto){ return broadcastDao.getList(dto); } }