BroadcastServiceImpl.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package com.welampiot.service.impl;
  2. import com.welampiot.dao.BroadcastDao;
  3. import com.welampiot.dto.BroadcastDTO;
  4. import com.welampiot.dto.BroadcastItemDTO;
  5. import com.welampiot.dto.BroadcastProListDTO;
  6. import com.welampiot.service.BroadcastService;
  7. import com.welampiot.vo.BroadcastItemVO;
  8. import com.welampiot.vo.BroadcastProListVO;
  9. import com.welampiot.vo.BroadcastVO;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import java.text.ParseException;
  13. import java.text.SimpleDateFormat;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. /**
  17. * ClassName: BroadcastServiceImpl
  18. * Package: com.welampiot.service.impl
  19. * Description:
  20. *
  21. * @Author: zhj_Start
  22. * @Create: 2023/4/17 - 11:19
  23. * @Version: v1.0
  24. */
  25. @Service
  26. public class BroadcastServiceImpl implements BroadcastService {
  27. @Autowired
  28. private BroadcastDao broadcastDao;
  29. @Override
  30. public BroadcastVO getDevListByBroadcastDTO(BroadcastDTO dto) {
  31. BroadcastVO vo = new BroadcastVO();
  32. vo.setTotal(broadcastDao.getTotalBySectionList(dto));
  33. vo.setOnlineTotal(broadcastDao.getOnlineTotalBySectionList(dto));
  34. List<BroadcastDTO> devList = broadcastDao.getDevListByBroadcastDTO(dto);
  35. List<BroadcastDTO> list = new ArrayList<>();
  36. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  37. devList.forEach(broadcastDTO ->{
  38. if (broadcastDTO.getOnline() != null && broadcastDTO.getOnline() == 1){
  39. broadcastDTO.setOnline(1);
  40. }else {
  41. broadcastDTO.setOnline(0);
  42. }
  43. if (broadcastDTO.getProName() == null){
  44. broadcastDTO.setProName("");
  45. }
  46. if (broadcastDTO.getLampPoleName() == null){
  47. broadcastDTO.setLampPoleName("");
  48. }
  49. if (broadcastDTO.getType() != null && broadcastDTO.getType() == 1){
  50. broadcastDTO.setType(1);
  51. }else {
  52. broadcastDTO.setType(0);
  53. }
  54. if (broadcastDTO.getIsPlay() != null && broadcastDTO.getIsPlay() == 1){
  55. broadcastDTO.setIsPlay(1);
  56. }else {
  57. broadcastDTO.setIsPlay(0);
  58. }
  59. if (broadcastDTO.getInstallDate() != null && !broadcastDTO.getInstallDate().equals("")){
  60. try {
  61. broadcastDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getInstallDate())));
  62. } catch (ParseException e) {
  63. throw new RuntimeException(e);
  64. }
  65. }else {
  66. broadcastDTO.setInstallDate("");
  67. }
  68. if (broadcastDTO.getExpirationDate() != null && !broadcastDTO.getExpirationDate().equals("")){
  69. try {
  70. broadcastDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getExpirationDate())));
  71. } catch (ParseException e) {
  72. throw new RuntimeException(e);
  73. }
  74. }else {
  75. broadcastDTO.setExpirationDate("");
  76. }
  77. list.add(broadcastDTO);
  78. });
  79. vo.setList(list);
  80. return vo;
  81. }
  82. @Override
  83. public BroadcastProListVO getProListByDTO(String username) {
  84. BroadcastProListVO vo = new BroadcastProListVO();
  85. Integer userId = broadcastDao.getUserIdByUserName(username);
  86. List<BroadcastProListDTO> proList = broadcastDao.getProListByDTO(userId);
  87. vo.setList(proList);
  88. return vo;
  89. }
  90. @Override
  91. public BroadcastItemVO getItemListByDTO(String username, Integer devId) {
  92. BroadcastItemVO vo = new BroadcastItemVO();
  93. Integer userId = broadcastDao.getUserIdByUserName(username);
  94. List<BroadcastItemDTO> itemList = broadcastDao.getItemListByDTO(userId, devId);
  95. List<BroadcastItemDTO> list = new ArrayList<>();
  96. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  97. itemList.forEach(broadcastItemDTO -> {
  98. if (broadcastItemDTO.getBroadcastStr() == null){
  99. broadcastItemDTO.setBroadcastStr("");
  100. }
  101. if (broadcastItemDTO.getProType() != null && broadcastItemDTO.getProType() == 1){
  102. broadcastItemDTO.setProType(1);
  103. }else {
  104. broadcastItemDTO.setProType(0);
  105. }
  106. if (broadcastItemDTO.getStatus() != null && broadcastItemDTO.getStatus() == 1){
  107. broadcastItemDTO.setStatus(1);
  108. }else {
  109. broadcastItemDTO.setStatus(0);
  110. }
  111. if (broadcastItemDTO.getCreateTime() != null && !broadcastItemDTO.getCreateTime().equals("")){
  112. try {
  113. broadcastItemDTO.setCreateTime(simpleDateFormat.format(simpleDateFormat.parse(broadcastItemDTO.getCreateTime())));
  114. } catch (ParseException e) {
  115. throw new RuntimeException(e);
  116. }
  117. }else {
  118. broadcastItemDTO.setCreateTime("");
  119. }
  120. list.add(broadcastItemDTO);
  121. });
  122. vo.setList(list);
  123. return vo;
  124. }
  125. @Override
  126. public void deleteBroadcastById(Integer id) {
  127. broadcastDao.deleteBroadcastById(id);
  128. }
  129. @Override
  130. public BroadcastDTO getBroadcastById(Integer id) {
  131. return broadcastDao.getBroadcastById(id);
  132. }
  133. @Override
  134. public Integer getBroadcastCountByLampPoleId(Integer lampPoleId) {
  135. return broadcastDao.getBroadcastCountByLampPoleId(lampPoleId);
  136. }
  137. @Override
  138. public BroadcastDTO getBroadcastDTOByLampPoleId(Integer lampPoleId) {
  139. return broadcastDao.getBroadcastDTOByLampPoleId(lampPoleId);
  140. }
  141. @Override
  142. public void updateLampPoleBroadcastData(BroadcastDTO dto) {
  143. broadcastDao.updateLampPoleBroadcastData(dto);
  144. }
  145. @Override
  146. public Integer checkBroadcastData(BroadcastDTO dto) {
  147. return broadcastDao.checkBroadcastData(dto);
  148. }
  149. @Override
  150. public void updateBroadcastById(BroadcastDTO dto) {
  151. broadcastDao.updateBroadcastById(dto);
  152. }
  153. @Override
  154. public List<BroadcastDTO> getListByIds(String ids) {
  155. return broadcastDao.getListByIds(ids);
  156. }
  157. @Override
  158. public Integer getTotalBySectionList(BroadcastDTO dto) {
  159. return broadcastDao.getTotalBySectionList(dto);
  160. }
  161. @Override
  162. public BroadcastDTO getOneDataByLampPoleId(Integer lampPoleId){
  163. return broadcastDao.getOneDataByLampPoleId(lampPoleId);
  164. }
  165. @Override
  166. public BroadcastDTO getData(Integer lampPoleId){
  167. return broadcastDao.getData(lampPoleId);
  168. }
  169. }