|
|
@@ -2,14 +2,18 @@ package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.ResultEnum;
|
|
|
+import com.welampiot.dto.GroupDTO;
|
|
|
import com.welampiot.dto.LampInfoDTO;
|
|
|
import com.welampiot.dto.NetworkDTO;
|
|
|
+import com.welampiot.service.GroupService;
|
|
|
import com.welampiot.service.LampService;
|
|
|
import com.welampiot.service.NetworkService;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.vo.GroupVO;
|
|
|
import com.welampiot.vo.InfoResponseVO;
|
|
|
import com.welampiot.vo.LampCountVO;
|
|
|
import com.welampiot.vo.LampListResponseVO;
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
@@ -19,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -33,7 +38,8 @@ public class LampController {
|
|
|
private ToolUtils toolUtils;
|
|
|
@Autowired
|
|
|
private NetworkService networkService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private GroupService groupService;
|
|
|
/**
|
|
|
* 灯控列表
|
|
|
* @param request
|
|
|
@@ -204,4 +210,138 @@ public class LampController {
|
|
|
}
|
|
|
return toolUtils.response("0000",version);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 灯控调光
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/dimming",method = RequestMethod.POST)
|
|
|
+ public BaseResult dimming(HttpServletRequest request){
|
|
|
+ Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
|
|
|
+ Integer light = request.getParameter("light") == null ? 0 : Integer.parseInt(request.getParameter("light"));
|
|
|
+ Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
|
|
|
+ LampInfoDTO lamp = lampService.getDetailsById(id, version);
|
|
|
+ if (lamp.getProtocolType() == 10){ // 4G
|
|
|
+ String sendTopic = "/Lamp/TransIn/"+lamp.getSn();
|
|
|
+ String backTopic = "/Lamp/TransOut/"+lamp.getSn();
|
|
|
+
|
|
|
+ if (lamp.getMode() == 1){ // B 路
|
|
|
+
|
|
|
+ }else { // A 路
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+// String lampId = request.getParameter("lampId");
|
|
|
+// if (lampId == null || lampId.length() == 0) return toolUtils.response("0007",version);
|
|
|
+// String[] split = lampId.split(",");
|
|
|
+// for (String id :split) {
|
|
|
+// int l = Integer.parseInt(id);
|
|
|
+// lampService.deleteById(l);
|
|
|
+// }
|
|
|
+ return toolUtils.response("0000",version);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新建分组选择灯控
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/selectLamp",method = RequestMethod.POST)
|
|
|
+ public BaseResult selectLamp(HttpServletRequest request){
|
|
|
+ String version = request.getParameter("version") == null ? "0" : request.getParameter("version");
|
|
|
+ String type = request.getParameter("type") == null ? "0" : request.getParameter("type");
|
|
|
+ String groupid = request.getParameter("groupid") == null || request.getParameter("groupid").length() == 0? "0" : request.getParameter("groupid");
|
|
|
+ System.out.println(toolUtils);
|
|
|
+ List sectionList = toolUtils.getSectionList(request);
|
|
|
+ GroupVO groupVO = new GroupVO();
|
|
|
+ groupVO.setVersion(Integer.valueOf(version));
|
|
|
+ groupVO.setId(Integer.valueOf(groupid));
|
|
|
+ groupVO.setSectionList(sectionList);
|
|
|
+ GroupDTO group = groupService.getDetailByVO(groupVO);
|
|
|
+ String[] lampArr = null;
|
|
|
+// if (!type.equals("0") && group != null){
|
|
|
+// where.put("lampid",group.getLampid());
|
|
|
+// }
|
|
|
+ if (group != null && group.getLampId() != null){
|
|
|
+ lampArr = group.getLampId().split(",");
|
|
|
+ }
|
|
|
+ LampListResponseVO lampListResponseVO = new LampListResponseVO();
|
|
|
+ lampListResponseVO.setVersion(Integer.valueOf(version));
|
|
|
+ lampListResponseVO.setSectionList(sectionList);
|
|
|
+ List<LampInfoDTO> lampList = lampService.groupSelectLamp(lampListResponseVO);
|
|
|
+
|
|
|
+// List<Map> maps = lampinfoMapper.selectLamp(where);
|
|
|
+// Map t_m;
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List list = new ArrayList<>();
|
|
|
+ for (LampInfoDTO lamp :lampList) {
|
|
|
+ if (lampArr != null && ArrayUtils.contains(lampArr,lamp.getId().toString())){
|
|
|
+ lamp.setSelect(1);
|
|
|
+ }else {
|
|
|
+ if (type.equals("1")) continue;
|
|
|
+ lamp.setSelect(0);
|
|
|
+ }
|
|
|
+ if (lamp.getLighteness() == 0){
|
|
|
+ lamp.setLampStatusStr("关");
|
|
|
+ }else {
|
|
|
+ lamp.setLampStatusStr("开");
|
|
|
+ }
|
|
|
+ list.add(lamp);
|
|
|
+ }
|
|
|
+// for (int i = 0; i < maps.size(); i++) {
|
|
|
+// t_m = maps.get(i);
|
|
|
+//// if ((t_m.get("number") == null || t_m.get("number").equals("")) && t_m.get("lamp_polle_id") != null) t_m.put("number",t_m.get("lpNumber"));
|
|
|
+// Integer lighteness = (Integer)t_m.get("lampStatus") == 0 ? 0 : (Integer) t_m.get("lighteness");
|
|
|
+// t_m.put("lighteness",lighteness);
|
|
|
+// t_m.put("current",String.format("%.2f",t_m.get("current")).toString());
|
|
|
+// if (t_m.get("control_type").equals("4") || t_m.get("control_type").equals("8")){
|
|
|
+// t_m.put("networkStatus",t_m.get("lampOnline"));
|
|
|
+// }
|
|
|
+// if (version.equals("0")){
|
|
|
+// t_m.put("lampStatusStr",t_m.get("lampStatus").equals("1") ? "开" : "关");
|
|
|
+// t_m.put("networkStatusStr",t_m.get("networkStatus").equals("1") ? "在线" : "离线");
|
|
|
+// } else if (version.equals("1")) {
|
|
|
+// t_m.put("lampStatusStr",t_m.get("lampStatus").equals("1") ? "On" : "Off");
|
|
|
+// t_m.put("networkStatusStr",t_m.get("networkStatus").equals("1") ? "Online" : "Off-line");
|
|
|
+// }else {
|
|
|
+// t_m.put("lampStatusStr",t_m.get("lampStatus").equals("1") ? "Открой" : "Гуань");
|
|
|
+// t_m.put("networkStatusStr",t_m.get("networkStatus").equals("1") ? "Онлайн" : "В автономном режиме");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (lampArr != null && ArrayUtils.contains(lampArr,t_m.get("id").toString())){
|
|
|
+// t_m.put("select",1);
|
|
|
+// }else {
|
|
|
+// t_m.put("select",0);
|
|
|
+// }
|
|
|
+// Date updateTime = (Date) t_m.get("updateTime");
|
|
|
+// if (updateTime != null){
|
|
|
+// long timezone = updateTime.getTime() + (int) t_m.get("timezone") * 3600;
|
|
|
+// updateTime = new Date(timezone);
|
|
|
+// t_m.put("updateTime",simpleDateFormat.format(updateTime));
|
|
|
+// }else {
|
|
|
+// t_m.put("updateTime","");
|
|
|
+// }
|
|
|
+// if ((t_m.get("protocoltype").equals("10") && t_m.get("control_type").equals("5")) || (t_m.get("protocoltype").equals("11") && t_m.get("control_type").equals("8")) || (t_m.get("protocoltype").equals("3") && t_m.get("control_type").equals("9")) || t_m.get("control_type").equals("25")){
|
|
|
+// String number = (String) t_m.get("number");
|
|
|
+// number += t_m.get("mode").equals("0") ? "-1" : "-2";
|
|
|
+// t_m.put("number",number);
|
|
|
+// }
|
|
|
+// if (Integer.parseInt(version) == 0){
|
|
|
+// t_m.put("area",t_m.get("carea"));
|
|
|
+// } else if (Integer.parseInt(version) == 1) {
|
|
|
+// t_m.put("area",t_m.get("earea"));
|
|
|
+// }else {
|
|
|
+// t_m.put("area",t_m.get("rarea"));
|
|
|
+// }
|
|
|
+// t_m.put("networkStatus",t_m.get("networkStatus").toString());
|
|
|
+// maps.set(i,t_m);
|
|
|
+// }
|
|
|
+// Map data = new HashMap<>();
|
|
|
+// data.put("list",maps);
|
|
|
+ LampListResponseVO lampListResponseVO1 = new LampListResponseVO();
|
|
|
+ lampListResponseVO1.setList(list);
|
|
|
+ return toolUtils.response("0000",Integer.parseInt(version),lampListResponseVO1);
|
|
|
+ }
|
|
|
}
|