|
@@ -7,10 +7,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
-import com.welampiot.configuration.FreqConfig;
|
|
|
-import com.welampiot.configuration.FreqMapConfig;
|
|
|
-import com.welampiot.configuration.QuHuiPlc;
|
|
|
-import com.welampiot.configuration.ZhongLightPlc;
|
|
|
+import com.welampiot.configuration.*;
|
|
|
import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.AESUtils;
|
|
@@ -47,6 +44,7 @@ import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@CrossOrigin
|
|
@@ -84,6 +82,8 @@ public class LampController {
|
|
|
private FreqMapConfig freqMapConfig;
|
|
|
@Autowired
|
|
|
private JwtUtil jwtUtil;
|
|
|
+ @Autowired
|
|
|
+ private LastSqlInterceptor lastSqlInterceptor; //获取sql语句
|
|
|
/**
|
|
|
* 灯控列表
|
|
|
* @param request
|
|
@@ -151,12 +151,11 @@ public class LampController {
|
|
|
LampInfoDTO detailsById = lampService.getDetailsById(lampId,version);
|
|
|
return BaseResult.success(detailsById);
|
|
|
}
|
|
|
-// @RequestMapping(value = "/getkk",method = RequestMethod.POST)
|
|
|
-//public Integer kk(HttpServletRequest request){
|
|
|
-// UserDTO user = toolUtils.getUser(request);
|
|
|
-// System.out.println("===dd===:"+user);
|
|
|
-// return user.getId();
|
|
|
-//}
|
|
|
+ @RequestMapping(value = "/getkk", method = RequestMethod.POST)
|
|
|
+ public Integer kk(HttpServletRequest request) {
|
|
|
+ toolUtils.addOpertaionLog(request,null,null,null,null,null,null,null,null,null,null,null,null,null);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
/**
|
|
|
* 添加编辑灯控
|
|
|
* @param request
|
|
@@ -233,6 +232,9 @@ public class LampController {
|
|
|
this.savePlcAddress(macAddress,sn);
|
|
|
}
|
|
|
}
|
|
|
+ String groupId = request.getParameter("groupId");
|
|
|
+ String lampPoleId = request.getParameter("lampPoleId");
|
|
|
+
|
|
|
Date day = new Date();
|
|
|
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String updateTime = sdf.format(day);
|
|
@@ -245,18 +247,26 @@ public class LampController {
|
|
|
lampInfo.setSectionId(sectionId);
|
|
|
lampInfo.setNumber(number);
|
|
|
|
|
|
- Integer byVO = lampService.findByVO(lampInfo);
|
|
|
- if (byVO > 0) return toolUtils.response(InterfaceResultEnum.NUMBER_EXIST_ERROR,version);
|
|
|
+ //若两灯的,只添加其中一个的就要判断了
|
|
|
+// Integer byVO = lampService.findByVO(lampInfo);
|
|
|
+// if (byVO > 0) return toolUtils.response(InterfaceResultEnum.NUMBER_EXIST_ERROR,version);
|
|
|
lampInfo.setSectionId(null);
|
|
|
lampInfo.setNumber(null);
|
|
|
lampInfo.setAddress(sn);
|
|
|
NetworkDTO networkData = new NetworkDTO();
|
|
|
//同一个plc下不允许有相同的序号/相同灯的地址
|
|
|
Integer header = 0; //灯头:0代表没,1代表灯头1,2代表灯头2
|
|
|
- Integer plcNetCount = 0; //0:没有创建 ,1: 创建过了
|
|
|
+ Integer plcNetCount = 0; //网关, 0:没有创建 ,1: 创建过了
|
|
|
if (protocolType == 11 && controlType != 26 && controlType != 27){
|
|
|
+ String otherDevAddr = ""; //另外一个
|
|
|
lampInfo.setMacAddress(macAddress);
|
|
|
if (controlType == 4 || controlType == 11 || controlType == 12 || controlType == 14 ){
|
|
|
+ //同一个路段下编号不允相同
|
|
|
+ LampInfoDTO newLamp = new LampInfoDTO();
|
|
|
+ newLamp.setNumber(number);
|
|
|
+ newLamp.setSectionId(sectionId);
|
|
|
+ Integer byVO = lampService.findByVO(newLamp);
|
|
|
+ if (byVO > 0) return toolUtils.response(InterfaceResultEnum.NUMBER_EXIST_ERROR,version);
|
|
|
//单灯的情况下是不允许有重复地址的
|
|
|
//灯地址
|
|
|
Integer macAddressTotal = lampService.checkData(lampInfo);
|
|
@@ -269,18 +279,44 @@ public class LampController {
|
|
|
return toolUtils.response(InterfaceResultEnum.PLC_ADDRESS_EXIST_ERROR,version);
|
|
|
}else {
|
|
|
//不存在或只存在一个灯头
|
|
|
- if (dtoList != null){
|
|
|
+ if (dtoList != null && dtoList.size() == 1){
|
|
|
//存在一个灯头
|
|
|
header = dtoList.get(0).getMode() + 1;
|
|
|
+ otherDevAddr = dtoList.get(0).getDevAddr();
|
|
|
+ }else {
|
|
|
+ //同一个路段下编号不允相同
|
|
|
+ LampInfoDTO newLamp = new LampInfoDTO();
|
|
|
+ newLamp.setNumber(number);
|
|
|
+ newLamp.setSectionId(sectionId);
|
|
|
+ Integer byVO = lampService.findByVO(newLamp);
|
|
|
+ if (byVO > 0) return toolUtils.response(InterfaceResultEnum.NUMBER_EXIST_ERROR,version);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//灯序号
|
|
|
- lampInfo.setMacAddress(null);
|
|
|
- lampInfo.setDevAddr(devAddr);
|
|
|
- Integer devAddrTotal = lampService.checkData(lampInfo);
|
|
|
- if (devAddrTotal > 0) return toolUtils.response(InterfaceResultEnum.PLC_SERIAL_NUMBER_EXIST_ERROR,version);
|
|
|
- lampInfo.setMacAddress(macAddress);
|
|
|
+ if (header == 0){
|
|
|
+ lampInfo.setMacAddress(null);
|
|
|
+ lampInfo.setDevAddr(devAddr);
|
|
|
+ Integer devAddrTotal = lampService.checkData(lampInfo);
|
|
|
+ if (devAddrTotal > 0) return toolUtils.response(InterfaceResultEnum.PLC_SERIAL_NUMBER_EXIST_ERROR,version);
|
|
|
+ lampInfo.setMacAddress(macAddress);
|
|
|
+ }else {
|
|
|
+ //双灯只添加其中一个
|
|
|
+ if (!devAddr.equals(otherDevAddr)){
|
|
|
+ //跟原来的不一样
|
|
|
+ return toolUtils.response(InterfaceResultEnum.PLC_SERIAL_NUMBER_SAME__ERROR,version);
|
|
|
+ }else {
|
|
|
+ lampInfo.setDevAddr(devAddr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //同一个路段下编号不允相同
|
|
|
+ LampInfoDTO newLamp = new LampInfoDTO();
|
|
|
+ newLamp.setNumber(number);
|
|
|
+ newLamp.setSectionId(sectionId);
|
|
|
+ Integer byVO = lampService.findByVO(newLamp);
|
|
|
+ if (byVO > 0) return toolUtils.response(InterfaceResultEnum.NUMBER_EXIST_ERROR,version);
|
|
|
}
|
|
|
if (protocolType == 13 || controlType == 26 || controlType == 27){
|
|
|
lampInfo.setMacAddress(macAddress);
|
|
@@ -300,20 +336,22 @@ public class LampController {
|
|
|
lampInfo.setNetworkId(network.getId());
|
|
|
}
|
|
|
Integer checkAddressTotal = lampService.checkData(lampInfo);
|
|
|
+
|
|
|
if (protocolType != 11 && protocolType != 5 && protocolType != 13 && checkAddressTotal > 0){
|
|
|
+
|
|
|
LampInfoDTO dataByVO = lampService.getDataByVO(lampInfo);
|
|
|
//section
|
|
|
SectionDTO sectionDTO = new SectionDTO();
|
|
|
- sectionDTO.setId(dataByVO.getId());
|
|
|
+ sectionDTO.setId(dataByVO.getSectionId());
|
|
|
sectionDTO= sectionService.getDataByVO(sectionDTO);
|
|
|
//location
|
|
|
GlobalLocationDTO areaData = new GlobalLocationDTO();
|
|
|
areaData.setId(sectionDTO.getPid());
|
|
|
areaData = globalLocationService.getDataByDto(areaData);
|
|
|
|
|
|
- String chinaMsg = "无线地址已存在,区域: "+areaData.getChineseName()+"-->路段:"+sectionDTO.getName()+"-->路灯编号:"+lampInfo.getNumber();
|
|
|
- String engMsg = "The wireless address already exists,area: "+areaData.getEnglishName()+"-->section:"+sectionDTO.getName()+"-->number:"+lampInfo.getNumber();
|
|
|
- String ruMsg = "Беспроводной адрес уже существует,область: "+areaData.getRuName()+"-->участок дороги:"+sectionDTO.getName()+"-->Номер фонаря:"+lampInfo.getNumber();
|
|
|
+ String chinaMsg = "无线模块地址已存在,区域: "+areaData.getChineseName()+"-->路段:"+sectionDTO.getName()+"-->路灯编号:"+dataByVO.getNumber();
|
|
|
+ String engMsg = "The wireless address already exists,area: "+areaData.getEnglishName()+"-->section:"+sectionDTO.getName()+"-->number:"+dataByVO.getNumber();
|
|
|
+ String ruMsg = "Беспроводной адрес уже существует,область: "+areaData.getRuName()+"-->участок дороги:"+sectionDTO.getName()+"-->Номер фонаря:"+dataByVO.getNumber();
|
|
|
if (version == 0){
|
|
|
String code = "0403";
|
|
|
if (version == 0){
|
|
@@ -328,20 +366,21 @@ public class LampController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
lampInfo.setBindStatus(bindStatus);
|
|
|
- String netAddress = "";
|
|
|
+ //String netAddress = "";
|
|
|
if (protocolType == 0 || protocolType == 3 || protocolType == 4 || protocolType == 5 || protocolType == 6 || protocolType == 7 || protocolType == 8 || protocolType == 9 || protocolType == 10 || protocolType == 11 || protocolType == 13){
|
|
|
lampInfo.setNetType(1);
|
|
|
//直连设备
|
|
|
if (protocolType == 11 || protocolType == 5){
|
|
|
- netAddress = sn;
|
|
|
+ //netAddress = sn;
|
|
|
//plc下有单灯控制器和双灯控制器
|
|
|
lampInfo.setBindStatus(0);
|
|
|
}else {
|
|
|
- netAddress = sn.length() == 13 ? String.valueOf(Integer.parseInt(sn,10)) : sn;
|
|
|
+ sn = sn.length() == 13 ? String.valueOf(Integer.parseInt(sn,10)) : sn;
|
|
|
}
|
|
|
//networkData = new NetworkDTO();
|
|
|
- networkData.setDeviceSn(netAddress);
|
|
|
+ networkData.setDeviceSn(sn);
|
|
|
NetworkDTO simpleData = networkService.getSimpleData(networkData);
|
|
|
//zigbee设备 plc
|
|
|
if (protocolType == 5 && controlType == 13){
|
|
@@ -363,6 +402,7 @@ public class LampController {
|
|
|
//成功
|
|
|
lampInfo.setLampCtrId(((ZhongLightPlcVO)lightObject).getLampCtrlId());
|
|
|
lampInfo.setUid(((ZhongLightPlcVO)lightObject).getUid());
|
|
|
+ lampInfo.setBindStatus(1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -391,7 +431,7 @@ public class LampController {
|
|
|
if (protocolType == 8 && (controlType == 29 || controlType == 33 || controlType == 19)) networkData.setDeviceType(4);
|
|
|
if (protocolType == 3 && controlType == 9) networkData.setDeviceType(4);
|
|
|
if (controlType == 16 || controlType == 20) networkData.setDeviceType(5);
|
|
|
- networkData.setNetworkName(netAddress);
|
|
|
+ networkData.setNetworkName(sn);
|
|
|
networkData.setNetType(1);
|
|
|
networkData.setCreateTime(updateTime);
|
|
|
networkData.setUserId(userId);
|
|
@@ -427,8 +467,8 @@ public class LampController {
|
|
|
JSONObject parseObject = JSON.parseObject(result);
|
|
|
Integer code = parseObject.getInteger("code");
|
|
|
if (code == 200){
|
|
|
- Integer networkId = networkService.add(networkData);
|
|
|
- lampInfo.setNetworkId(networkId);
|
|
|
+ networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkData.getId());
|
|
|
} else {
|
|
|
String msg = parseObject.getString("msg");
|
|
|
BaseResult<Object> objectBaseResult = new BaseResult<>(code.toString(), msg, new Object());
|
|
@@ -437,8 +477,8 @@ public class LampController {
|
|
|
}
|
|
|
}else {
|
|
|
//力合微 plc
|
|
|
- Integer networkId = networkService.add(networkData);
|
|
|
- lampInfo.setNetworkId(networkId);
|
|
|
+ networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkData.getId());
|
|
|
}
|
|
|
}else {
|
|
|
NetworkDTO network = networkService.getSimpleData(networkData);
|
|
@@ -450,13 +490,13 @@ public class LampController {
|
|
|
networkData.setProtocolType(protocolType);
|
|
|
networkData.setAreaId(areaId);
|
|
|
networkData.setSectionId(sectionId);
|
|
|
- networkData.setDeviceSn(netAddress);
|
|
|
- networkData.setNetworkName(netAddress);
|
|
|
+ networkData.setDeviceSn(sn);
|
|
|
+ networkData.setNetworkName(sn);
|
|
|
networkData.setNetType(1);
|
|
|
networkData.setCreateTime(updateTime);
|
|
|
}
|
|
|
- Integer networkId = networkService.add(networkData);
|
|
|
- lampInfo.setNetworkId(networkId);
|
|
|
+ networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkData.getId());
|
|
|
}
|
|
|
SectionDTO sectionDTO = new SectionDTO();
|
|
|
sectionDTO.setId(sectionId);
|
|
@@ -468,101 +508,176 @@ public class LampController {
|
|
|
|
|
|
lampInfo.setCreateTime(updateTime);
|
|
|
//添加plc控制器节点 - 启慧
|
|
|
- if (protocolType == 11 && (controlType == 11 || controlType == 12 || controlType == 14)){
|
|
|
+ if (protocolType == 11 && (controlType == 11 || controlType == 12 || controlType == 14)) {
|
|
|
String url = "childnode/deviceRegister";
|
|
|
-// $nodeType = $this->selectNodeType($data['ratedpower']);
|
|
|
+ String nodeType = this.selectNodeType(power);
|
|
|
+ if (nodeType == null || nodeType.length() == 0) return toolUtils.response(InterfaceResultEnum.POWER_SELECT_ERROR,version);
|
|
|
+ JSONObject qiObject = new JSONObject();
|
|
|
+ if (groupId != null && groupId.length() != 0){
|
|
|
+ String[] groupIds = groupId.split(",");
|
|
|
+ List<GroupDTO> list = groupService.getListByIds(groupIds);
|
|
|
+ //有分组 (只有: 1- 255)
|
|
|
+ for (GroupDTO item:list) {
|
|
|
+ Integer groupNumber = Integer.parseInt(item.getNumber());
|
|
|
+ if (groupNumber < 1 || groupNumber > 255){
|
|
|
+ //分组没有在规定的范围内
|
|
|
+ return toolUtils.response(InterfaceResultEnum.GROUP_NUMBER_RAND_ERROR,version);
|
|
|
+ }else {
|
|
|
+ //注意:nodeId是12位数的,不够时,前面补0
|
|
|
+ String nodeId = "";
|
|
|
+ String zero = "";
|
|
|
+ if (macAddress.length() <= 12){
|
|
|
+ for (int i = 0; i < 12 - macAddress.length();i++){
|
|
|
+ zero += "0";
|
|
|
+ }
|
|
|
+ nodeId = zero+macAddress;
|
|
|
+ }else {
|
|
|
+ //大于12位数了
|
|
|
+ return toolUtils.response(InterfaceResultEnum.FILL_LAMP_ADDRESS__ERROR,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ qiObject.put("nodeId",nodeId);
|
|
|
+ qiObject.put("nodeType",nodeType);
|
|
|
+ qiObject.put("deviceId",sn);
|
|
|
+ qiObject.put("groupNum",groupNumber);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //没有分组的
|
|
|
+ //注意:nodeId是12位数的,不够时,前面补0
|
|
|
+ String nodeId = "";
|
|
|
+ String zero = "";
|
|
|
+ if (macAddress.length() <= 12){
|
|
|
+ for (int i = 0; i < 12 - macAddress.length();i++){
|
|
|
+ zero += "0";
|
|
|
+ }
|
|
|
+ nodeId = zero+macAddress;
|
|
|
+ }else {
|
|
|
+ //大于12位数了
|
|
|
+ return toolUtils.response(InterfaceResultEnum.FILL_LAMP_ADDRESS__ERROR,version);
|
|
|
+ }
|
|
|
+ qiObject.put("nodeId",nodeId);
|
|
|
+ qiObject.put("nodeType",nodeType);
|
|
|
+ qiObject.put("deviceId",sn);
|
|
|
+ }
|
|
|
+ String respone = this.quiHuiPlcDevice(url, qiObject, 4);
|
|
|
+ if (respone == null || respone.length() == 0){
|
|
|
+ return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ }else {
|
|
|
+ JSONObject parseObject = JSON.parseObject(respone);
|
|
|
+ Integer code = parseObject.getInteger("code");
|
|
|
+ if (code != 200){
|
|
|
+ String msg = parseObject.getString("msg");
|
|
|
+ BaseResult<Object> objectBaseResult = new BaseResult<>(code.toString(), msg, new Object());
|
|
|
+ return objectBaseResult;
|
|
|
+ }else {
|
|
|
+ lampInfo.setBindStatus(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-// if (($protocoltype == 11 && $data['control_type'] == 11) || ($protocoltype == 11 && $data['control_type'] == 12) || ($protocoltype == 11 && $data['control_type'] == 14)){
|
|
|
-//
|
|
|
-// $url = 'childnode/deviceRegister';
|
|
|
-// $nodeType = $this->selectNodeType($data['ratedpower']);
|
|
|
-//
|
|
|
-// if (empty($nodeType)) exit(json_result('0323',$this->response['0323']));
|
|
|
-// $params = '';
|
|
|
-// if (!empty($groupid)){
|
|
|
-// //有分组 (只有: 1- 255)
|
|
|
-// $groupid = implode(',', explode(',', $groupid));
|
|
|
-// $groupList = $this->db->query('select id,`name` from `group` where id in ('.$groupid.')')->result_array();
|
|
|
-// foreach ($groupList as $key=>$item){
|
|
|
-// if (is_numeric($item)){
|
|
|
-// if (intval($item) > 225 || intval($item) < 1){
|
|
|
-// //分组没有在规定的范围内
|
|
|
-// exit(json_result('0420',$this->response['0420']));
|
|
|
-// }else{
|
|
|
-// //注意:nodeId是12位数的,不够时,前面补0
|
|
|
-// $nodeId = '';
|
|
|
-// $zero = '';
|
|
|
-// if (mb_strlen($data['macAddress']) <= 12){
|
|
|
-// for ($i = 0; $i < 12-(mb_strlen($data['macAddress'])); $i ++){
|
|
|
-// $zero .= '0';
|
|
|
-// }
|
|
|
-// $nodeId = $zero.$data['macAddress'];
|
|
|
-// }else{
|
|
|
-// //大于12位数了
|
|
|
-// exit(json_result('0324',$this->response['0324']));
|
|
|
-// }
|
|
|
-// $params = array('nodeId'=>$nodeId,'nodeType'=>$nodeType,'deviceId'=>$data['address'],'groupNum'=>intval($item));
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// //分组没有在规定的范围内
|
|
|
-// exit(json_result('0420',$this->response['0420']));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// //没有分组的
|
|
|
-// //注意:nodeId是12位数的,不够时,前面补0
|
|
|
-// $nodeId = '';
|
|
|
-// $zero = '';
|
|
|
-// if (mb_strlen($data['macAddress']) <= 12){
|
|
|
-// for ($i = 0; $i < 12-(mb_strlen($data['macAddress'])); $i ++){
|
|
|
-// $zero .= '0';
|
|
|
-// }
|
|
|
-// $nodeId = $zero.$data['macAddress'];
|
|
|
-// }else{
|
|
|
-// //大于12位数了
|
|
|
-// exit(json_result('0324',$this->response['0324']));
|
|
|
-// }
|
|
|
-// $params = array('nodeId'=>$nodeId,'nodeType'=>$nodeType,'deviceId'=>$data['address']);
|
|
|
-// }
|
|
|
-//
|
|
|
-// $result = $this->plcDevice($url,$params,3);
|
|
|
-// $resultObj = json_decode($result);
|
|
|
-//
|
|
|
-// if ($resultObj->code != 200){
|
|
|
-// //不成功
|
|
|
-// exit(json_result($resultObj->code,$resultObj->msg));
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- //添加网关
|
|
|
- NetworkDTO networkDTO = new NetworkDTO();
|
|
|
- networkDTO.setDeviceSn(sn);
|
|
|
- //查询有没有网关
|
|
|
- Integer count = networkService.checkNetworkData(networkDTO);
|
|
|
- if (count == 0){
|
|
|
- //添加网关
|
|
|
- //networkService.addNetworkData();
|
|
|
- }
|
|
|
- //添加灯控
|
|
|
- LampInfoDTO lampInfoDTO = new LampInfoDTO();
|
|
|
- lampInfoDTO.setProtocolType(protocolType);
|
|
|
- lampInfoDTO.setSn(sn);
|
|
|
- lampInfoDTO.setNumber(number);
|
|
|
- lampInfoDTO.setSectionId(sectionId);
|
|
|
- lampInfoDTO.setName(name);
|
|
|
- lampInfoDTO.setLatitude(Float.valueOf(latitude));
|
|
|
- lampInfoDTO.setLongitude(Float.valueOf(longitude));
|
|
|
- lampInfoDTO.setNumber(number);
|
|
|
- lampInfoDTO.setSn(sn);
|
|
|
- lampInfoDTO.setAreaId(areaId);
|
|
|
- lampInfoDTO.setControlType(controlType);
|
|
|
- lampInfoDTO.setInstallDate(installDate);
|
|
|
- lampInfoDTO.setExpirationDate(expirationDate);
|
|
|
- lampInfoDTO.setRatedPower(power);
|
|
|
- lampInfoDTO.setDevAddr(devAddr);
|
|
|
- lampInfoDTO.setFreqId(Integer.parseInt(freqId));
|
|
|
- lampInfoDTO.setZegbeeSectionId(loopNumber);
|
|
|
- return lampService.add(lampInfoDTO);
|
|
|
+
|
|
|
+ lampInfo.setControlType(controlType);
|
|
|
+ lampInfo.setRatedPower(power);
|
|
|
+ lampInfo.setLongitude(Float.valueOf(longitude));
|
|
|
+ lampInfo.setLatitude(Float.valueOf(latitude));
|
|
|
+ lampInfo.setAreaId(areaId);
|
|
|
+ lampInfo.setSectionId(sectionId);
|
|
|
+ lampInfo.setAddress(sn);
|
|
|
+ lampInfo.setNumber(number);
|
|
|
+ lampInfo.setName(name);
|
|
|
+
|
|
|
+ if (protocolType == 11 && controlType == 8 && header > 0){
|
|
|
+ //添加其中一个灯头
|
|
|
+ if (header == 1){//灯头1
|
|
|
+ //设置灯头2
|
|
|
+ lampInfo.setMode(1);
|
|
|
+ }else {//灯头2
|
|
|
+ //设置灯头1
|
|
|
+ lampInfo.setMode(0);
|
|
|
+ }
|
|
|
+ lampService.addByDto(lampInfo);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ lampService.addByDto(lampInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改了 4G 双控 plc 双控 nb 双控 蓝牙双灯
|
|
|
+ if (protocolType == 10 && (controlType == 5 || controlType == 22 || controlType == 34) || (protocolType == 11 && controlType == 8 && header == 0) || (protocolType == 3 && controlType == 9) || controlType == 25 || controlType == 27 || controlType ==29){
|
|
|
+ lampInfo.setMode(1);
|
|
|
+ lampService.addByDto(lampInfo);
|
|
|
+ }
|
|
|
+ String lastSql = lastSqlInterceptor.sqlContent; //插入的sql语句
|
|
|
+ if (lampPoleId != null && lampPoleId.length() != 0){
|
|
|
+ toolUtils.setPoleType(Integer.parseInt(lampPoleId),0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加到分组
|
|
|
+ if (groupId != null && groupId.length() != 0){
|
|
|
+ String[] groupIdArr = groupId.split(",");
|
|
|
+ List<GroupDTO> groupDTOList = groupService.getListByIds(groupIdArr);
|
|
|
+ for (GroupDTO item:groupDTOList) {
|
|
|
+ String[] lampArr = item.getLampId().split(",");
|
|
|
+ //是否包含某个元素
|
|
|
+ boolean ifContain = Arrays.asList(lampArr).contains(lampInfo.getId());
|
|
|
+ if (ifContain == false){
|
|
|
+ //转换成list
|
|
|
+ List<String> list = new ArrayList<>(Arrays.asList(lampArr));
|
|
|
+ list.add(lampInfo.getId().toString());
|
|
|
+ //list数组按规定拼接成字符串
|
|
|
+ String newLampId= list.stream().collect(Collectors.joining(","));
|
|
|
+ //更新
|
|
|
+ item.setLampId(newLampId);
|
|
|
+ groupService.updateGroupLampId(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ networkData = networkService.getSimpleData(networkData);
|
|
|
+ Integer lampCount = networkData.getLampCount();
|
|
|
+
|
|
|
+ if (controlType == 1 || controlType == 3 || controlType == 5 || controlType == 8 || controlType == 9 || controlType == 22){
|
|
|
+ //更新lampcount
|
|
|
+ //如果两灯就是添加2个
|
|
|
+ if (lampCount == null || lampCount == 0){
|
|
|
+ networkData.setLampCount(2);
|
|
|
+ }else {
|
|
|
+ if (header > 0 && controlType == 8){
|
|
|
+ //只增加一个
|
|
|
+ lampCount = lampCount + 1;
|
|
|
+ networkData.setLampCount(lampCount);
|
|
|
+ }else {
|
|
|
+ lampCount = lampCount + 2;
|
|
|
+ networkData.setLampCount(lampCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ networkService.updateSimDate(networkData);
|
|
|
+ }else {
|
|
|
+ //单灯
|
|
|
+ //如果两灯就是添加1个
|
|
|
+ if (protocolType != 11 && protocolType != 5){
|
|
|
+ networkData.setLampCount(1);
|
|
|
+ networkService.updateSimDate(networkData);
|
|
|
+ }else if((protocolType == 11 || protocolType == 5) && controlType != 26 && controlType != 27) {
|
|
|
+ //plc可以带很多灯 ,//zigbee也是带多个灯
|
|
|
+ if (lampCount == null || lampCount == 0){
|
|
|
+ networkData.setLampCount(1);
|
|
|
+ }else {
|
|
|
+ lampCount = lampCount + 1;
|
|
|
+ networkData.setLampCount(lampCount);
|
|
|
+ }
|
|
|
+ networkService.updateSimDate(networkData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String cRemark = "添加路灯 区域:"+areaDTO.getChineseName()+"->路段:"+sectionDTO.getName()+"->路灯编号:"+number+" id:"+lampInfo.getId();
|
|
|
+ String eRemark = "Add lamp area:"+areaDTO.getEnglishName()+"->section:"+sectionDTO.getName()+"->number:"+number+" id:"+lampInfo.getId();
|
|
|
+ String rRemark = "Добавить зону светильников:"+areaDTO.getRuName()+"->участок дороги:"+sectionDTO.getName()+"->нумерация:"+number+" id:"+lampInfo.getId();
|
|
|
+ toolUtils.addOpertaionLog(request, "添加", cRemark, 0, 1, 1, number, areaDTO.getChineseName(), sectionDTO.getName(), sn, sectionId, sectionDTO.getId(), lampInfo.getId(), lastSql);
|
|
|
+ toolUtils.addOpertaionLog(request, "Insert", eRemark, 1,1,1, number, areaDTO.getEnglishName(), sectionDTO.getName(), sn, sectionId, sectionDTO.getId(), lampInfo.getId(), lastSql);
|
|
|
+ toolUtils.addOpertaionLog(request,"Подкючено",rRemark,2,1,1,number,areaDTO.getRuName(),sectionDTO.getName(),sn,sectionId,sectionDTO.getId(), lampInfo.getId(),lastSql);
|
|
|
+
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+
|
|
|
}else { // 编辑
|
|
|
// LampInfoDTO oldLamp = lampService.getDetailsById(lampId,version);
|
|
|
// if (oldLamp.getProtocolType() != protocolType){
|
|
@@ -866,7 +981,62 @@ public class LampController {
|
|
|
}
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
}
|
|
|
-
|
|
|
+ private String selectNodeType(Integer power){
|
|
|
+ String nodeType = "";
|
|
|
+ switch (power){
|
|
|
+ case 30:
|
|
|
+ nodeType = "01";
|
|
|
+ break;
|
|
|
+ case 40:
|
|
|
+ nodeType = "02";
|
|
|
+ break;
|
|
|
+ case 50:
|
|
|
+ nodeType = "50";
|
|
|
+ break;
|
|
|
+ case 60:
|
|
|
+ nodeType = "06";
|
|
|
+ break;
|
|
|
+ case 75:
|
|
|
+ nodeType = "0A";
|
|
|
+ break;
|
|
|
+ case 80:
|
|
|
+ nodeType = "12";
|
|
|
+ break;
|
|
|
+ case 90:
|
|
|
+ nodeType = "15";
|
|
|
+ break;
|
|
|
+ case 100:
|
|
|
+ nodeType = "19";
|
|
|
+ break;
|
|
|
+ case 120:
|
|
|
+ nodeType = "1D";
|
|
|
+ break;
|
|
|
+ case 150:
|
|
|
+ nodeType = "2C";
|
|
|
+ break;
|
|
|
+ case 160:
|
|
|
+ nodeType = "27";
|
|
|
+ break;
|
|
|
+ case 180:
|
|
|
+ nodeType = "36";
|
|
|
+ break;
|
|
|
+ case 185:
|
|
|
+ nodeType = "38";
|
|
|
+ break;
|
|
|
+ case 200:
|
|
|
+ nodeType = "40";
|
|
|
+ break;
|
|
|
+ case 240:
|
|
|
+ nodeType = "45";
|
|
|
+ break;
|
|
|
+ case 260:
|
|
|
+ nodeType = "48";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ nodeType = "";
|
|
|
+ }
|
|
|
+ return nodeType;
|
|
|
+ }
|
|
|
//中灯 - 调光
|
|
|
private Object getToken(){
|
|
|
String url = zhongLightPlc.getZhongUrl()+"query_token";
|
|
@@ -1263,7 +1433,7 @@ public class LampController {
|
|
|
String bodyJsonString = bodyJson.toString();
|
|
|
return bodyJsonString;
|
|
|
}
|
|
|
- //广东启慧-调光/集中器设备注册(网关)
|
|
|
+ //广东启慧-调光/集中器设备注册(网关)/控制器
|
|
|
private String quiHuiPlcDevice(String url,JSONObject params,Integer timeOut) {
|
|
|
String plcUrl = quHuiPlc.getUrl()+url;
|
|
|
Random random = new Random();
|