|
@@ -0,0 +1,131 @@
|
|
|
+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){
|
|
|
+ try {
|
|
|
+ broadcastDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getInstallDate())));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ broadcastDTO.setInstallDate("");
|
|
|
+ }
|
|
|
+ if (broadcastDTO.getExpirationDate() != null){
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+}
|