|
@@ -921,46 +921,49 @@ class Lampcontrol extends Base_Controller {
|
|
|
$ids = explode(",", $lamp_ids);
|
|
|
|
|
|
// 获取灯控信息
|
|
|
- $dataArr = $this->Lamp_model->getBatch($ids);
|
|
|
+ $dataArr = $this->Lamp_model->get_list(['id'=>$ids]);
|
|
|
|
|
|
// 修改网络跟项目下灯控数量
|
|
|
foreach ($dataArr as $data) {
|
|
|
- $data['faultcount'] = $data['isfaulted'] > 0 ? 1 : 0;
|
|
|
- $this->Network_model->minus_lamp_count($data);
|
|
|
+ $temp = array();
|
|
|
+ $temp['faultcount'] = $data['isfaulted'] > 0 ? 1 : 0;
|
|
|
+ $temp['lampcount'] = $data['lampcount'];
|
|
|
+ $temp['projectid'] = $data['projectid'];
|
|
|
+ // $this->Network_model->minus_lamp_count($data);
|
|
|
$this->Project_model->minus_lamp_count($data);
|
|
|
- $netData = $this->Network_model->getOne($data['networkid'],'gatewaytype,protocoltype');
|
|
|
- if ($netData['protocoltype'] == 6) $this->remove_device('00000000'.$data['address']);
|
|
|
- if (isset($netData) && $netData['gatewaytype'] == 'direct' && !empty($data['networkid'])) {// 直连设备
|
|
|
- // 删除网络
|
|
|
- // $this->Zone_model->delOne($data['networkid']);
|
|
|
- $this->Network_model->delData(array('id'=>$data['networkid']));
|
|
|
- $cmdstr = '{"cmd_type":"delete_network_cmd","cmd_id":'.$data['networkid'].'}';
|
|
|
- // send_cmd($cmdstr,0);
|
|
|
- if (isset($netData['protocoltype']) && $netData['protocoltype'] != 0) {
|
|
|
- $cmdret = send_cmd($cmdstr,1,0,$netData['protocoltype']);
|
|
|
- if ($cmdret === false) {
|
|
|
- sleep(1);
|
|
|
- $cmdret = send_cmd($cmdstr,1,0,$netData['protocoltype']);
|
|
|
- }
|
|
|
- }else{
|
|
|
- $cmdret = send_cmd($cmdstr,0,0,$netData['protocoltype']);
|
|
|
- if ($cmdret === false) {
|
|
|
- sleep(1);
|
|
|
- $cmdret = send_cmd($cmdstr,0,0,$netData['protocoltype']);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // $netData = $this->Network_model->getOne($data['networkid'],'gatewaytype,protocoltype');
|
|
|
+ // if ($netData['protocoltype'] == 6) $this->remove_device('00000000'.$data['address']);
|
|
|
+ // if (isset($netData) && $netData['gatewaytype'] == 'direct' && !empty($data['networkid'])) {// 直连设备
|
|
|
+ // // 删除网络
|
|
|
+ // // $this->Zone_model->delOne($data['networkid']);
|
|
|
+ // $this->Network_model->delData(array('id'=>$data['networkid']));
|
|
|
+ // $cmdstr = '{"cmd_type":"delete_network_cmd","cmd_id":'.$data['networkid'].'}';
|
|
|
+ // // send_cmd($cmdstr,0);
|
|
|
+ // if (isset($netData['protocoltype']) && $netData['protocoltype'] != 0) {
|
|
|
+ // $cmdret = send_cmd($cmdstr,1,0,$netData['protocoltype']);
|
|
|
+ // if ($cmdret === false) {
|
|
|
+ // sleep(1);
|
|
|
+ // $cmdret = send_cmd($cmdstr,1,0,$netData['protocoltype']);
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // $cmdret = send_cmd($cmdstr,0,0,$netData['protocoltype']);
|
|
|
+ // if ($cmdret === false) {
|
|
|
+ // sleep(1);
|
|
|
+ // $cmdret = send_cmd($cmdstr,0,0,$netData['protocoltype']);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
// 删除灯控告警信息
|
|
|
- $this->Alarm_model->delBatch($ids, 'lampid');
|
|
|
-
|
|
|
+ $this->Alarm_model->delete(['lampid'=>$ids]);
|
|
|
|
|
|
foreach ($ids as $v) {
|
|
|
$lampData = $this->Lamp_model->get_project_company(array('L.id'=>$v),'P.projectname,N.networkname,L.number,L.address');
|
|
|
- $this->add_operation_log('delete',"删除\"{$lampData['projectname']}\"项目下的\"{$lampData['networkname']}\"网络里的编号为\"{$lampData['number']}\"、无线模块地址为\"{$lampData['address']}\"的路灯",0);
|
|
|
- $this->add_operation_log('delete',"Delete lamp:\"{$lampData['number']}\".Wireless module address:\"{$lampData['address']}\".Project name:\"{$lampData['projectname']}\".Network name:\"{$lampData['networkname']}\"",0,1);
|
|
|
+ $this->add_operation_log('delete',"删除\"{$lampData['projectname']}\"项目下的编号为\"{$lampData['number']}\"、无线模块地址为\"{$lampData['address']}\"的路灯",0);
|
|
|
+ $this->add_operation_log('delete',"Delete lamp:\"{$lampData['number']}\".Wireless module address:\"{$lampData['address']}\".Project name:\"{$lampData['projectname']}\"",0,1);
|
|
|
}
|
|
|
- $this->Lamp_model->delBatch($ids);
|
|
|
+ $this->Lamp_model->delete(['id'=>$ids]);
|
|
|
+ $this->RealtimeInfoLog_model->delete(['lampid'=>$ids]);
|
|
|
|
|
|
exit(json_result('0000', $this->response['0000'], array()));
|
|
|
}
|