|
@@ -2,10 +2,13 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.dto.LampInfoDTO;
|
|
|
import com.welampiot.dto.LoopDTO;
|
|
|
+import com.welampiot.service.LampService;
|
|
|
import com.welampiot.service.LoopService;
|
|
|
import com.welampiot.utils.ExcelUtil;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.LampVO;
|
|
|
import com.welampiot.vo.LoopDetailVO;
|
|
|
import com.welampiot.vo.LoopVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -39,6 +42,9 @@ public class LoopController {
|
|
|
@Autowired
|
|
|
private ToolUtils toolUtils;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LampService lampService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取回路列表
|
|
|
* @param request 路段筛选,分页
|
|
@@ -298,4 +304,67 @@ public class LoopController {
|
|
|
}
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给回路中添加灯控
|
|
|
+ * @param vo 回路id,灯控id
|
|
|
+ * @return 给回路中添加灯控
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addLamp", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> addLamp(LampVO vo) {
|
|
|
+ LampVO lampVO = LampVO.getLampVO(vo);
|
|
|
+ Integer version = lampVO.getVersion();
|
|
|
+ Integer loopId = lampVO.getLoopId();
|
|
|
+ if (loopId == null || loopId == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ String lampId = lampVO.getLampId();
|
|
|
+ if (lampId == null || lampId.isEmpty())
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ String[] split = lampId.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ Integer integer = Integer.valueOf(s);
|
|
|
+ LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
+ lampInfoDTO.setId(integer);
|
|
|
+ lampInfoDTO.setLoopId(loopId);
|
|
|
+ lampService.updateLampInfoForLoopId(lampInfoDTO);
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新建、编辑回路路灯列表
|
|
|
+ * @param request 回路id,路段id
|
|
|
+ * @return 新建、编辑回路路灯列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/selectLamp", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> selectLamp(HttpServletRequest request) {
|
|
|
+ Integer version = (Integer) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ Integer sectionId = (Integer) toolUtils.getRequestContent(request,"sectionId",1);
|
|
|
+ Integer loopId = (Integer) toolUtils.getRequestContent(request,"loopId",1);
|
|
|
+ LampVO lampVO = new LampVO();
|
|
|
+ lampVO.setLoopId(loopId);
|
|
|
+ lampVO.setVersion(version);
|
|
|
+ lampVO.setSectionId(sectionId);
|
|
|
+ lampVO.setSectionList(toolUtils.getSectionList(request));
|
|
|
+ List<LampInfoDTO> lampInfoList = lampService.getLampInfoListForGroup(lampVO);
|
|
|
+ lampInfoList.forEach(dto -> {
|
|
|
+ if (dto.getLampStatus() != null && dto.getLampStatus() == 1) {
|
|
|
+ dto.setLampStatusStr("开灯");
|
|
|
+ } else {
|
|
|
+ dto.setLampStatusStr("关灯");
|
|
|
+ }
|
|
|
+ if (loopId != 0) {
|
|
|
+ if (dto.getLoopId() != null && dto.getLoopId().equals(loopId)) {
|
|
|
+ dto.setSelect(1);
|
|
|
+ } else {
|
|
|
+ dto.setSelect(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dto.setSelect(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ LampVO lampVO1 = new LampVO();
|
|
|
+ lampVO1.setList(lampInfoList);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lampVO1);
|
|
|
+ }
|
|
|
}
|