|
@@ -7,11 +7,14 @@ 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.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.AESUtils;
|
|
|
+import com.welampiot.utils.JwtUtil;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.vo.*;
|
|
|
import org.apache.commons.codec.DecoderException;
|
|
@@ -77,7 +80,10 @@ public class LampController {
|
|
|
private AESUtils aesUtils;
|
|
|
@Autowired
|
|
|
private PlcAddressService plcAddressService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private FreqMapConfig freqMapConfig;
|
|
|
+ @Autowired
|
|
|
+ private JwtUtil jwtUtil;
|
|
|
/**
|
|
|
* 灯控列表
|
|
|
* @param request
|
|
@@ -145,7 +151,12 @@ 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();
|
|
|
+//}
|
|
|
/**
|
|
|
* 添加编辑灯控
|
|
|
* @param request
|
|
@@ -211,7 +222,10 @@ public class LampController {
|
|
|
}
|
|
|
|
|
|
String macAddress = request.getParameter("macAddress");
|
|
|
-
|
|
|
+ if (protocolType == 11 || protocolType == 5){
|
|
|
+ //macAddress的值不能为空
|
|
|
+ if (macAddress == null) return toolUtils.response(InterfaceResultEnum.LACK_PLC_MACADDRESS__ERROR,version);
|
|
|
+ }
|
|
|
if (controlType == 26 || controlType == 27){
|
|
|
if (macAddress != null && sn != null){
|
|
|
bindStatus = 0;
|
|
@@ -219,6 +233,11 @@ public class LampController {
|
|
|
this.savePlcAddress(macAddress,sn);
|
|
|
}
|
|
|
}
|
|
|
+ Date day = new Date();
|
|
|
+ SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String updateTime = sdf.format(day);
|
|
|
+
|
|
|
+ Integer userId = toolUtils.getUser(request).getId();
|
|
|
|
|
|
if (lampId == 0){ // 添加
|
|
|
//同一个路段下不能有相同的编号
|
|
@@ -231,19 +250,39 @@ public class LampController {
|
|
|
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: 创建过了
|
|
|
if (protocolType == 11 && controlType != 26 && controlType != 27){
|
|
|
lampInfo.setMacAddress(macAddress);
|
|
|
- //灯地址
|
|
|
- Integer macAddressTotal = lampService.checkData(lampInfo);
|
|
|
- if (macAddressTotal > 0) return toolUtils.response(InterfaceResultEnum.PLC_ADDRESS_EXIST_ERROR,version);
|
|
|
- //灯序号
|
|
|
+ if (controlType == 4 || controlType == 11 || controlType == 12 || controlType == 14 ){
|
|
|
+ //单灯的情况下是不允许有重复地址的
|
|
|
+ //灯地址
|
|
|
+ Integer macAddressTotal = lampService.checkData(lampInfo);
|
|
|
+ if (macAddressTotal > 0) return toolUtils.response(InterfaceResultEnum.PLC_ADDRESS_EXIST_ERROR,version);
|
|
|
+ } else if (controlType == 8) {
|
|
|
+ //双灯的情况,检查是否有两个了,若有则不能重复,若没有,则要知道有了哪个灯头
|
|
|
+ List<LampInfoDTO> dtoList = lampService.getListByDto(lampInfo);
|
|
|
+ if (dtoList != null && dtoList.size() == 2){
|
|
|
+ //已经存在
|
|
|
+ return toolUtils.response(InterfaceResultEnum.PLC_ADDRESS_EXIST_ERROR,version);
|
|
|
+ }else {
|
|
|
+ //不存在或只存在一个灯头
|
|
|
+ if (dtoList != null){
|
|
|
+ //存在一个灯头
|
|
|
+ header = dtoList.get(0).getMode() + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //灯序号
|
|
|
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 (protocolType == 13 || controlType == 26 || controlType ==27){
|
|
|
+ if (protocolType == 13 || controlType == 26 || controlType == 27){
|
|
|
lampInfo.setMacAddress(macAddress);
|
|
|
//lampInfo.setAddress(sn);
|
|
|
Integer devAddrTotal = lampService.checkData(lampInfo);
|
|
@@ -251,10 +290,14 @@ public class LampController {
|
|
|
}
|
|
|
if (protocolType == 5){
|
|
|
//zigbee设备先判断有没有添加网关
|
|
|
- NetworkDTO networkData = new NetworkDTO();
|
|
|
+ //NetworkDTO network = new NetworkDTO();
|
|
|
networkData.setDeviceSn(sn);
|
|
|
Integer networkTotal = networkService.checkNetworkData(networkData);
|
|
|
if (networkTotal == 0) return toolUtils.response(InterfaceResultEnum.LACK_PLC_ADDRESS__ERROR,version);
|
|
|
+
|
|
|
+ //获取网关id
|
|
|
+ NetworkDTO network = networkService.getSimpleData(networkData);
|
|
|
+ lampInfo.setNetworkId(network.getId());
|
|
|
}
|
|
|
Integer checkAddressTotal = lampService.checkData(lampInfo);
|
|
|
if (protocolType != 11 && protocolType != 5 && protocolType != 13 && checkAddressTotal > 0){
|
|
@@ -297,10 +340,10 @@ public class LampController {
|
|
|
}else {
|
|
|
netAddress = sn.length() == 13 ? String.valueOf(Integer.parseInt(sn,10)) : sn;
|
|
|
}
|
|
|
- NetworkDTO networkData = new NetworkDTO();
|
|
|
- networkData.setDeviceSn(sn);
|
|
|
+ //networkData = new NetworkDTO();
|
|
|
+ networkData.setDeviceSn(netAddress);
|
|
|
NetworkDTO simpleData = networkService.getSimpleData(networkData);
|
|
|
- //zigbee设备
|
|
|
+ //zigbee设备 plc
|
|
|
if (protocolType == 5 && controlType == 13){
|
|
|
//先添加控制器,再添加灯具
|
|
|
lampInfo.setMacAddress(macAddress);
|
|
@@ -333,68 +376,165 @@ public class LampController {
|
|
|
}
|
|
|
lampInfo.setAddress(sn);
|
|
|
}
|
|
|
- if (protocolType != 11 && simpleData != null){
|
|
|
- return toolUtils.response(InterfaceResultEnum.DEVICE_ADDRESS_EXITS_ERROR,version);
|
|
|
+ // plc只创建一个网络就可以了
|
|
|
+ if (simpleData != null){
|
|
|
+ if (protocolType == 11 && (controlType != 26 && controlType != 27)){
|
|
|
+ plcNetCount = 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
-// if ($protocoltype == 0 || $protocoltype == 3 || $protocoltype == 4 || $protocoltype == 5 || $protocoltype == 6
|
|
|
-// || $protocoltype == 7 || $protocoltype == 8 || $protocoltype == 9 || $protocoltype == 10 || $protocoltype == 11 || $protocoltype == 13) {
|
|
|
-// $data['net_type'] = 1;
|
|
|
+ networkData.setGatewayType("direct");
|
|
|
+ networkData.setProtocolType(protocolType);
|
|
|
+ networkData.setAreaId(areaId);
|
|
|
+ networkData.setSectionId(sectionId);
|
|
|
+ if (protocolType == 10) networkData.setDeviceType(4);
|
|
|
+ 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.setNetType(1);
|
|
|
+ networkData.setCreateTime(updateTime);
|
|
|
+ networkData.setUserId(userId);
|
|
|
+ if (protocolType == 6) this.addDevice(sn,freqId);
|
|
|
+ if (protocolType == 7){
|
|
|
+ //添加onenet
|
|
|
+ String deviceOnenet = toolUtils.addDeviceOnenet(sn);
|
|
|
+ if (deviceOnenet != null && deviceOnenet.length() != 0){
|
|
|
+ JSONObject onenetObject = JSON.parseObject(deviceOnenet);
|
|
|
+ JSONObject data = onenetObject.getJSONObject("data");
|
|
|
+ String onenetId = data.getString("device_id");
|
|
|
+ if (onenetId != null && onenetId.length() != 0){
|
|
|
+ lampInfo.setDeviceId(onenetId);
|
|
|
+ networkData.setDeviceId(onenetId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (protocolType == 10 && (controlType == 7 || controlType == 6 || controlType == 15 || controlType == 19 || controlType == 21 || controlType == 30 || controlType == 31 || controlType == 32 || controlType == 35)) lampInfo.setMode(1);
|
|
|
+ if (protocolType == 8 && (controlType == 19 || controlType == 23 || controlType == 33 || controlType == 37)) lampInfo.setMode(1);
|
|
|
+ if (protocolType == 11 && controlType != 26 && controlType != 27){
|
|
|
+ if (plcNetCount == 0){
|
|
|
+ if (controlType != 4 && controlType != 8){
|
|
|
+ //广东启慧 - plc
|
|
|
+ String url = "concentrator/deviceRegister";
|
|
|
+ JSONObject qihuiObject = new JSONObject();
|
|
|
+ qihuiObject.put("deviceId",sn);
|
|
|
+ //添加网关
|
|
|
+ String result = this.quiHuiPlcDevice(url, qihuiObject, 4);
|
|
|
+ if (result == null || result.length() == 0){
|
|
|
+ return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ }else {
|
|
|
+ JSONObject parseObject = JSON.parseObject(result);
|
|
|
+ Integer code = parseObject.getInteger("code");
|
|
|
+ if (code == 200){
|
|
|
+ Integer networkId = networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkId);
|
|
|
+ } else {
|
|
|
+ String msg = parseObject.getString("msg");
|
|
|
+ BaseResult<Object> objectBaseResult = new BaseResult<>(code.toString(), msg, new Object());
|
|
|
+ return objectBaseResult;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //力合微 plc
|
|
|
+ Integer networkId = networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkId);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ NetworkDTO network = networkService.getSimpleData(networkData);
|
|
|
+ lampInfo.setNetworkId(network.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (protocolType == 1){
|
|
|
+ networkData.setGatewayType("direct");
|
|
|
+ networkData.setProtocolType(protocolType);
|
|
|
+ networkData.setAreaId(areaId);
|
|
|
+ networkData.setSectionId(sectionId);
|
|
|
+ networkData.setDeviceSn(netAddress);
|
|
|
+ networkData.setNetworkName(netAddress);
|
|
|
+ networkData.setNetType(1);
|
|
|
+ networkData.setCreateTime(updateTime);
|
|
|
+ }
|
|
|
+ Integer networkId = networkService.add(networkData);
|
|
|
+ lampInfo.setNetworkId(networkId);
|
|
|
+ }
|
|
|
+ SectionDTO sectionDTO = new SectionDTO();
|
|
|
+ sectionDTO.setId(sectionId);
|
|
|
+ sectionDTO = sectionService.getDataByVO(sectionDTO);
|
|
|
+
|
|
|
+ GlobalLocationDTO areaDTO = new GlobalLocationDTO();
|
|
|
+ areaDTO.setId(sectionDTO.getPid());
|
|
|
+ areaDTO = globalLocationService.getDataByDto(areaDTO);
|
|
|
+
|
|
|
+ lampInfo.setCreateTime(updateTime);
|
|
|
+ //添加plc控制器节点 - 启慧
|
|
|
+ if (protocolType == 11 && (controlType == 11 || controlType == 12 || controlType == 14)){
|
|
|
+ String url = "childnode/deviceRegister";
|
|
|
+// $nodeType = $this->selectNodeType($data['ratedpower']);
|
|
|
+ }
|
|
|
+// if (($protocoltype == 11 && $data['control_type'] == 11) || ($protocoltype == 11 && $data['control_type'] == 12) || ($protocoltype == 11 && $data['control_type'] == 14)){
|
|
|
//
|
|
|
-// if ( $protocoltype != 11 && $protocoltype != 13 && $protocoltype != 5 && !empty($net_info)) {
|
|
|
-// $lamp_info = $this->Lampinfo_model->get_one(array('networkid'=>$net_info['id']),'id');
|
|
|
-// if (!empty($lamp_info)) {
|
|
|
-// $this->Network_model->delete(array('id'=>$net_info['id']));
|
|
|
-// }
|
|
|
-// }
|
|
|
+// $url = 'childnode/deviceRegister';
|
|
|
+// $nodeType = $this->selectNodeType($data['ratedpower']);
|
|
|
//
|
|
|
-// // if ( $protocoltype != 11 && $this->Network_model->getDataCount(array('devicesn'=>$number))) {
|
|
|
-// // exit(json_result('0309',$this->response['0309'],array()));
|
|
|
-// // }
|
|
|
-// // plc只创建一个网络就可以了
|
|
|
-// $plcNetCount = 0; //0:没有创建 ,1: 创建过了
|
|
|
-// if ($this->Network_model->getDataCount(array('devicesn'=>$number))) {
|
|
|
-// if ($protocoltype == 11 && ($data['control_type'] != 26 && $data['control_type'] != 27)){
|
|
|
-// $plcNetCount = 1;
|
|
|
+// 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);
|
|
|
//
|
|
|
-// $networkData['gatewaytype'] = 'direct';
|
|
|
-// $networkData['protocoltype'] = empty($protocoltype) ? 0 : $protocoltype;
|
|
|
-// $networkData['areaid'] = $data['areaid'];
|
|
|
-// $networkData['sectionid'] = $data['sectionid'];
|
|
|
-// $networkData['devicesn'] = $number;
|
|
|
-// if ($protocoltype == 10) $networkData['devicetype'] = 4;
|
|
|
-// if ($protocoltype == 8 && ($data['control_type'] == 29 || $data['control_type'] == 33)) $networkData['devicetype'] = 4;
|
|
|
-// if ($protocoltype == 3 && $data['control_type'] == 9) $networkData['devicetype'] = 4;
|
|
|
-// if ($protocoltype == 8 && $data['control_type'] == 19) $networkData['devicetype'] = 4;
|
|
|
-// if ($control_type == 16 || $control_type == 20) {
|
|
|
-// $networkData['devicetype'] = 5;
|
|
|
-// }
|
|
|
-// $networkData['network_name'] = $number;
|
|
|
-// $networkData['net_type'] = 1;
|
|
|
-// $networkData['createtime'] = date('Y-m-d H:i:s',time());
|
|
|
-// $networkData['userId'] = $userId;
|
|
|
-//
|
|
|
-// //$data['networkid'] = $this->Network_model->add($networkData);
|
|
|
-// if ($protocoltype == 6) $this->add_device($data['address'],$freqId);
|
|
|
-// if($protocoltype ==7 ) {
|
|
|
-// $onenet=$this->add_device_onenet($data['address']);
|
|
|
-// $file = fopen('./file/onenet_group_cmdURL.txt', 'a+');
|
|
|
-// fwrite($file, date('Y-m-d H:i:s').'----'.json_encode($onenet).' ');
|
|
|
-// fclose($file);
|
|
|
-// if (isset($onenet["data"])) {
|
|
|
-// $onenetId=$onenet['data']['device_id'];
|
|
|
-// if($onenetId){
|
|
|
-// $data['deviceid']=$onenetId;
|
|
|
-// $networkData['deviceid']=$onenetId;
|
|
|
-// }
|
|
|
-// }
|
|
|
+// if ($resultObj->code != 200){
|
|
|
+// //不成功
|
|
|
+// exit(json_result($resultObj->code,$resultObj->msg));
|
|
|
// }
|
|
|
-// }
|
|
|
- //添加网关
|
|
|
+
|
|
|
+
|
|
|
+ //添加网关
|
|
|
NetworkDTO networkDTO = new NetworkDTO();
|
|
|
networkDTO.setDeviceSn(sn);
|
|
|
//查询有没有网关
|
|
@@ -471,6 +611,46 @@ public class LampController {
|
|
|
plcAddressService.insertDataByVO(plcAddressDTO);
|
|
|
}
|
|
|
}
|
|
|
+ // 添加设备
|
|
|
+ protected String addDevice(String deviceId,String freqId){
|
|
|
+ Map<String, FreqConfig> maps = freqMapConfig.getMaps();
|
|
|
+ FreqConfig freqConfig = maps.get(freqId);
|
|
|
+ String deviceProfileID = "";
|
|
|
+ String applicationID = "";
|
|
|
+ if (freqConfig != null){
|
|
|
+ deviceProfileID = freqConfig.getDeviceProfileID();
|
|
|
+ applicationID = freqConfig.getApplicationID();
|
|
|
+ }
|
|
|
+ JSONObject device = new JSONObject();
|
|
|
+ device.put("applicationID",applicationID);
|
|
|
+ device.put("description",deviceId);
|
|
|
+ device.put("devEUI","00000000"+deviceId);
|
|
|
+ device.put("deviceProfileID",deviceProfileID);
|
|
|
+ device.put("name",deviceId);
|
|
|
+ device.put("referenceAltitude",0);
|
|
|
+ device.put("skipFCntCheck",true);
|
|
|
+ device.put("tags",new Object());
|
|
|
+ device.put("variables",new Object());
|
|
|
+
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("device",device);
|
|
|
+
|
|
|
+ String token = jwtUtil.signatureToToken();
|
|
|
+ String url = "http://47.112.108.98:8090/api/devices";
|
|
|
+ String respone = null;
|
|
|
+ try {
|
|
|
+ respone = toolUtils.sendHttp("post", url, data.toString(), token, null, 5, null, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
+ System.out.println("=====dddd:"+respone);
|
|
|
+ if (respone == null){
|
|
|
+ respone = jwtUtil.setActivate(deviceId);
|
|
|
+ System.out.println("=====再次:"+respone);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
/**
|
|
|
* 删除灯控
|
|
|
* @param request
|
|
@@ -608,8 +788,8 @@ public class LampController {
|
|
|
jsonObject.put("nodeId",macAddress);
|
|
|
jsonObject.put("ab",lamp.getMode()+1);
|
|
|
jsonObject.put("luminance",light);
|
|
|
- //发送命令
|
|
|
- String result = this.quiHuiPlcDeviceDimming(url, jsonObject, 4);
|
|
|
+ //发送命令-调光
|
|
|
+ String result = this.quiHuiPlcDevice(url, jsonObject, 4);
|
|
|
|
|
|
if (result == null || result.length() == 0){
|
|
|
return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
@@ -700,7 +880,7 @@ public class LampController {
|
|
|
String bodyStr = this.encryptAndMd5(objectString);
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = toolUtils.sendHttp("post", url, bodyStr,3);
|
|
|
+ result = toolUtils.sendHttp("post", url, bodyStr,3, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
@@ -767,7 +947,7 @@ public class LampController {
|
|
|
|
|
|
String respone = null;
|
|
|
try {
|
|
|
- respone = toolUtils.sendHttp("post",url,bodyJsonString,tokenObject.getToken(),null,4);
|
|
|
+ respone = toolUtils.sendHttp("post",url,bodyJsonString,tokenObject.getToken(),null,4,"Bearer", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
JSONObject parseObject = JSON.parseObject(respone);
|
|
|
System.out.println("======ddd:"+parseObject);
|
|
|
Integer ret = parseObject.getInteger("Ret");
|
|
@@ -855,7 +1035,7 @@ public class LampController {
|
|
|
|
|
|
String respone = null;
|
|
|
try {
|
|
|
- respone = toolUtils.sendHttp("post",url,bodyStr,token,sessionId,4);
|
|
|
+ respone = toolUtils.sendHttp("post",url,bodyStr,token,sessionId,4,"Bearer", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
System.out.println("=====diming:"+respone);
|
|
|
JSONObject parseObject = JSON.parseObject(respone);
|
|
|
Integer ret = parseObject.getInteger("Ret");
|
|
@@ -939,7 +1119,7 @@ public class LampController {
|
|
|
String sessionId = ((ZhongLightPlcVO) loginObject).getSessionId();
|
|
|
String respone = null;
|
|
|
try {
|
|
|
- respone = toolUtils.sendHttp("post", url, bodyStr, token, sessionId, 5);
|
|
|
+ respone = toolUtils.sendHttp("post", url, bodyStr, token, sessionId, 5,"Bearer", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
System.out.println("===dd:"+respone);
|
|
|
|
|
|
JSONObject parseObject = JSON.parseObject(respone);
|
|
@@ -1012,7 +1192,7 @@ public class LampController {
|
|
|
String sessionId = ((ZhongLightPlcVO) loginObject).getSessionId();
|
|
|
String respone = null;
|
|
|
try {
|
|
|
- respone = toolUtils.sendHttp("post", url, bodyStr, token, sessionId, 5);
|
|
|
+ respone = toolUtils.sendHttp("post", url, bodyStr, token, sessionId, 5,"Bearer", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
System.out.println("===light:"+respone);
|
|
|
|
|
|
JSONObject parseObject = JSON.parseObject(respone);
|
|
@@ -1083,8 +1263,8 @@ public class LampController {
|
|
|
String bodyJsonString = bodyJson.toString();
|
|
|
return bodyJsonString;
|
|
|
}
|
|
|
- //广东启慧-调光
|
|
|
- private String quiHuiPlcDeviceDimming(String url,JSONObject params,Integer timeOut) {
|
|
|
+ //广东启慧-调光/集中器设备注册(网关)
|
|
|
+ private String quiHuiPlcDevice(String url,JSONObject params,Integer timeOut) {
|
|
|
String plcUrl = quHuiPlc.getUrl()+url;
|
|
|
Random random = new Random();
|
|
|
int min = 10000;
|
|
@@ -1111,12 +1291,46 @@ public class LampController {
|
|
|
//发送post请求
|
|
|
String result = null;
|
|
|
try {
|
|
|
- result = toolUtils.sendHttp("post",plcUrl, json, 4);
|
|
|
+ result = toolUtils.sendHttp("post",plcUrl, json, timeOut, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+ //广东启慧-集中器设备注册(网关)
|
|
|
+// private String plcDevice(String url,String params,Integer timeOut){
|
|
|
+// String plcUrl = quHuiPlc.getUrl()+url;
|
|
|
+// Random random = new Random();
|
|
|
+// int min = 10000;
|
|
|
+// int max = 99999999;
|
|
|
+// String id = "wecloud_"+(random.nextInt(max-min) + min);
|
|
|
+// long timestamp = System.currentTimeMillis() / 1000;//单位是秒
|
|
|
+// String sign = quHuiPlc.getClientId()+timestamp+id+quHuiPlc.getClientSecret();
|
|
|
+// String md5Sign = DigestUtils.md5DigestAsHex(sign.getBytes()); //md5加密
|
|
|
+//
|
|
|
+// HashMap<String, Object> map = new HashMap<>();
|
|
|
+// map.put("ver","1.0");
|
|
|
+// map.put("client_id",quHuiPlc.getClientId());
|
|
|
+// map.put("timestamp",timestamp); //用map,timestamp不会打包成字符串,jsonObject会打包成字符串的
|
|
|
+// map.put("id",id);
|
|
|
+// map.put("sign",md5Sign);
|
|
|
+// map.put("params",params);
|
|
|
+// ObjectMapper mapper = new ObjectMapper();
|
|
|
+// String json = null;
|
|
|
+// try {
|
|
|
+// json = mapper.writeValueAsString(map).toString();
|
|
|
+// } catch (JsonProcessingException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// //发送post请求
|
|
|
+// String result = null;
|
|
|
+// try {
|
|
|
+// result = toolUtils.sendHttp("post",plcUrl, json, timeOut, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON);
|
|
|
+// } catch (IOException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// return result;
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 新建分组选择灯控
|