|
|
@@ -1,9 +1,12 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
-import com.welampiot.dto.ScreenDTO;
|
|
|
-import com.welampiot.service.ScreenService;
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.dto.*;
|
|
|
+import com.welampiot.service.*;
|
|
|
+import com.welampiot.utils.SHH2Util;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.ProgramVO;
|
|
|
import com.welampiot.vo.ScreenVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
@@ -12,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.IOException;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* ClassName: ScreenController
|
|
|
@@ -33,6 +40,18 @@ public class ScreenController {
|
|
|
@Autowired
|
|
|
private ToolUtils toolUtils;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProgramService programService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProgramInfoService programInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProgramInfoItemService programInfoItemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取屏幕下拉列表
|
|
|
* @param request
|
|
|
@@ -45,4 +64,119 @@ public class ScreenController {
|
|
|
ScreenVO vo = screenService.getScreenNavByDTO(dto);
|
|
|
return BaseResult.success(vo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 节目列表
|
|
|
+ * @param request username
|
|
|
+ * @return 节目列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/programList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> programList(HttpServletRequest request)
|
|
|
+ throws NoSuchFieldException, IllegalAccessException, IOException {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+ UserDTO userDTO = userService.queryUserIdByUsername(username);
|
|
|
+ if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ List<ProgramDTO> programList = programService.getProgramListByUserid(userDTO.getId());
|
|
|
+ List<ProgramDTO> list = new ArrayList<>();
|
|
|
+ for (ProgramDTO programDTO : programList) {
|
|
|
+ if (userDTO.getId() != null && userDTO.getId() != 0) {
|
|
|
+ programDTO.setCreator(username);
|
|
|
+ }
|
|
|
+ /*if (programDTO.getFileType() != null && (programDTO.getFileType() == 2 || programDTO.getFileType() == 1)) {
|
|
|
+ if (programDTO.getPath() != null && !programDTO.getPath().equals("")) {
|
|
|
+ String fileSize = toolUtils.getFileSize(programDTO.getPath());
|
|
|
+ if (fileSize != null) {
|
|
|
+ programDTO.setFileSize(fileSize + "M");
|
|
|
+ } else {
|
|
|
+ programDTO.setFileSize("0M");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ if (programDTO.getFileType() != null && programDTO.getFileType() == 3) {
|
|
|
+ programDTO.setFileTypeStr("液位监测");
|
|
|
+ } else if (programDTO.getFileType() != null && programDTO.getFileType() == 2) {
|
|
|
+ programDTO.setFileTypeStr("视屏");
|
|
|
+ } else if (programDTO.getFileType() != null && programDTO.getFileType() == 1) {
|
|
|
+ programDTO.setFileTypeStr("图片");
|
|
|
+ } else {
|
|
|
+ programDTO.setFileTypeStr("压缩文件");
|
|
|
+ }
|
|
|
+ if (programDTO.getType() != null && programDTO.getType() == 2) {
|
|
|
+ ProgramInfoDTO programInfoDTO = programInfoService.getProgramInfoByProgramId(programDTO.getId());
|
|
|
+ if (programInfoDTO == null) {
|
|
|
+ list.add(programDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (programInfoDTO.getType() != null && programInfoDTO.getType() == 1) {
|
|
|
+ programDTO.setProgramType(1);
|
|
|
+ } else {
|
|
|
+ programDTO.setProgramType(0);
|
|
|
+ }
|
|
|
+ if (programInfoDTO.getBeginDate() != null && !programInfoDTO.getBeginDate().equals("")) {
|
|
|
+ programDTO.setBeginDate(programInfoDTO.getBeginDate());
|
|
|
+ } else {
|
|
|
+ programDTO.setBeginDate("");
|
|
|
+ }
|
|
|
+ if (programInfoDTO.getEndDate() != null && !programInfoDTO.getEndDate().equals("")) {
|
|
|
+ programDTO.setEndDate(programInfoDTO.getEndDate());
|
|
|
+ } else {
|
|
|
+ programDTO.setEndDate("");
|
|
|
+ }
|
|
|
+ List<ProgramTimeDTO> timeList = new ArrayList<>();
|
|
|
+ for (int i = 1; i <= 10; i++) {
|
|
|
+ Field beginTimeField = programInfoDTO.getClass().getDeclaredField("beginTime" + i); // 获取time属性的值
|
|
|
+ Field endTimeField = programInfoDTO.getClass().getDeclaredField("endTime" + i);
|
|
|
+ beginTimeField.setAccessible(true); // 设置可以访问
|
|
|
+ endTimeField.setAccessible(true);
|
|
|
+ String beginTime = (String) beginTimeField.get(programInfoDTO);
|
|
|
+ String endTime = (String) endTimeField.get(programInfoDTO);
|
|
|
+ if (beginTime != null && !beginTime.equals("") && endTime != null && !endTime.equals("")) {
|
|
|
+ timeList.add(new ProgramTimeDTO(beginTime,endTime));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ programDTO.setTimeList(timeList);
|
|
|
+ List<ProgramInfoItemDTO> programItemList = programInfoItemService.getProgramItemListByInfoId(programInfoDTO.getId());
|
|
|
+ List<ProgramInfoItemDTO> sourceList = new ArrayList<>();
|
|
|
+ for (ProgramInfoItemDTO dto : programItemList) {
|
|
|
+ if (dto != null) {
|
|
|
+ if (dto.getSourceId() != null && dto.getTime() != null && dto.getType() != null) {
|
|
|
+ sourceList.add(new ProgramInfoItemDTO(dto.getSourceId(),dto.getTime(),dto.getType()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ programDTO.setSourceList(sourceList);
|
|
|
+ }
|
|
|
+ list.add(programDTO);
|
|
|
+ }
|
|
|
+ ProgramVO programVO = new ProgramVO();
|
|
|
+ programVO.setDataList(list);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,programVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除节目
|
|
|
+ * @param request programId
|
|
|
+ * @return 删除数据及文件
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/del", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> del(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer programId = (Integer) toolUtils.getRequestContent(request,"programId",1);
|
|
|
+ if (programId == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ ProgramDTO programDTO = programService.getProgramDTOById(programId);
|
|
|
+ if (programDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ programService.deleteProgramDataById(programId);
|
|
|
+ if (programDTO.getPath() != null && !programDTO.getPath().equals("")) {
|
|
|
+ SHH2Util.removeSipFile(programDTO.getPath());
|
|
|
+ }
|
|
|
+ if (programDTO.getType() != null && programDTO.getType() == 2) {
|
|
|
+ ProgramInfoDTO programInfo = programInfoService.getProgramInfoByProgramId(programId);
|
|
|
+ if (programInfo != null && programInfo.getId() != null && programInfo.getId() != 0) {
|
|
|
+ programInfoService.deleteProgramInfoDataById(programInfo.getId());
|
|
|
+ programInfoItemService.deleteProgramInfoItemDataById(programInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|