123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 com.welampiot.vo.BroadcastVO;
- 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 BroadcastVO getDevListByBroadcastDTO(BroadcastDTO dto) {
- BroadcastVO vo = new BroadcastVO();
- vo.setTotal(broadcastDao.getTotalBySectionList(dto));
- vo.setOnlineTotal(broadcastDao.getOnlineTotalBySectionList(dto));
- List<BroadcastDTO> devList = broadcastDao.getDevListByBroadcastDTO(dto);
- List<BroadcastDTO> 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<BroadcastProListDTO> 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<BroadcastItemDTO> itemList = broadcastDao.getItemListByDTO(userId, devId);
- List<BroadcastItemDTO> 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<BroadcastDTO> 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);
- }
- }
|