render ( "/test", array() );
}
function categoryApi(){
Doo::loadModel ( 'L_category' );
$L_category = new L_category ();
$category=$L_category->getCategoryBySoft();
header ( 'Content-Type:text/html;charset=utf-8' );
echo json_encode(array('status'=>1,'categoryList'=>$category),JSON_UNESCAPED_UNICODE);die;
}
function productApi(){
Doo::loadModel ( 'product' );
$product = new product ();
$product=$product->getProudct();
header ( 'Content-Type:text/html;charset=utf-8' );
echo json_encode(array('status'=>1,'productList'=>$product),JSON_UNESCAPED_UNICODE);die;
}
function addLockApi(){
$longleList=isset($_POST['longle'])?$_POST['longle']:"";
//$longleList='[{"key_num":"ZH-04400","serialnumber":"273800F808338043","product":"全国专业+固化清单全功能+全国专业","make_day":"2020/1/2 17:44:37","alloted_time":"","version":"","cid":"6","title":"江西办","licences":"0"}]';
//echo $longleList.'dddd';die;
header ( 'Content-Type:text/html;charset=utf-8' );
if($longleList!=""){
Doo::loadModel ( 'longle' );
Doo::loadModel ( 'longle_log' );
//$exlArray=$this->_format_excel_to_array(DOO::conf()->SITE_PATH."upload/".iconv("UTF-8", "GB2312", $path));
//file_put_contents ( "protected/config/longle2.bak", $longleList );
$longleList=json_decode($longleList,TRUE);
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'锁数据不正确'),JSON_UNESCAPED_UNICODE);die;
}
//数组格式化,新增字段需要在这新增
$longleList=$this->array_unique_fb($longleList);
// print_r($longleList);
//$category=$L_category->getCategoryById($cid);
try {
Doo::db()->beginTransaction();
foreach ($longleList as $key=>$value){
// echo 'key_num like "%'.$value['key_num'].'%" or SerialNumber like "%'.$value['serialnumber'].'%"';
$longle = new longle ();
$repeatDetail=$longle->getOne(array (
'where' => 'key_num like "%'.$value['key_num'].'%" or SerialNumber like "%'.$value['serialnumber'].'%"',
'limit' => '1',
'asArray' => TRUE
));
if(!empty($repeatDetail)){
echo json_encode(array('status'=>3,'dataDetail'=>$repeatDetail,'msg'=>'已存在该锁的数据'),JSON_UNESCAPED_UNICODE);die;
}
//锁记录
$longle = new longle ();
$longle->key_num=$value['key_num'];
$longle->product=$value['product'];
$longle->make_day=$value['make_day'];
$longle->alloted_time=$value['alloted_time'];
$longle->status=1;
$longle->statusT="生成";
$longle->cid=$value['cid'];
$longle->category=$value['title'];
$longle->SerialNumber=$value['serialnumber'];
$longle->version=$value['version'];
$longle->licences=$value['licences'];
$lid=$longle->insert();
//锁日志记录
$longle_log=new longle_log();
$longle_log->lid=$lid;
$longle_log->status=1;
$longle_log->statusT="生成";
$longle_log->operator='软件生成';
$longle_log->product=$longle->product;
$longle_log->category='总部';
$longle_log->dateline=date("Y-m-d");
$id=$longle_log->insert();
break;
}
//记录日常行为
Doo::loadModel("action_log");
$action_log=new action_log();
$action_log->action='总部软件生成'.$longleList[0]['key_num'].'等'.count($longleList).'个锁';
$action_log->sid=43;
$action_log->cid=12;
$action_log->class=$action_log->iconGenerate;
$action_log->updatetime=date("Y-m-d");
$action_log->time=date("H:i");
$action_log->status=11;
$action_log->insert();
Doo::db()->commit();
} catch (Exception $e) {
echo json_encode(array('status'=>2,'msg'=>'数据录入发生异常'),JSON_UNESCAPED_UNICODE);
//print $e->getMessage();
die;
}
echo json_encode(array('status'=>1,'msg'=>'入库'.count($longleList).'个'),JSON_UNESCAPED_UNICODE);die;
}else{
echo json_encode(array('status'=>2,'msg'=>'请求参数不正确或者为空'),JSON_UNESCAPED_UNICODE);die;
}
}
function updateLockApi(){
/* $serialnumber = $this->get_args ( 'serialnumber' ) ? $this->get_args ( 'serialnumber' ) : "";
$alloted_time = $this->get_args ( 'alloted_time' ) ? $this->get_args ( 'alloted_time' ) : '';
$product = $this->get_args ( 'product' ) ? $this->get_args ( 'product' ) : "";
//$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 0;//5升级 10延期
$UpdateStr = $this->get_args ( 'UpdateStr' ) ? $this->get_args ( 'UpdateStr' ) : "";
$UpdateFile = $this->get_args ( 'UpdateFile' ) ? $this->get_args ( 'UpdateFile' ) : "";
$AuthorizeStr = $this->get_args ( 'AuthorizeStr' ) ? $this->get_args ( 'AuthorizeStr' ) : "";
$AuthorizeFile = $this->get_args ( 'AuthorizeFile' ) ? $this->get_args ( 'AuthorizeFile' ) : "";
$version = $this->get_args ( 'version' ) ? $this->get_args ( 'version' ) : "";
$licences = $this->get_args ( 'licences' ) ? $this->get_args ( 'licences' ) : ""; */
$longleList=isset($_POST['longle'])?$_POST['longle']:"";
//$longleList='[{"serialnumber":"168600076BAA3300","product":"全国专业+固化清单全功能+广东专业+全国项目专业+内蒙养护+定额排版+贵州标后预算+广东项目专业+标后预算+广东算量+结算决算-全功能+全国算量+全国专业(新定额)+广东专业","alloted_time":"","version":"","licences":"","UpdateStr":"0E5343205570646174652046696C655C53634C6F630A000000000100002B305E9593E44844FE8FAC07873FF470D991DDEC5D6828EBF41F373588739F5C18D13441D73894F6BD6C430BBE6E167AC62554F6997CA615B5A13E5DFC7AF2D60A1AA47820FA2ED268100ED71072943393C8B75D3314D074DE9798FF75F80E7AE562AEC80E022189B518C84ABC7D68F01DF1BA532ED68FDC77BE9BAC4A15B4D144CAD0CE4880D94CEBA12C409006C0DAD2B65E2AACDFE9425EEB4E95CF08027308FAB81DFA8CFE9BD8AC95D3602B439CE41BBB38CA9E8378D1C7229320ACA1545F0705E8B34DB048E7C12E68145F1A961D12442801897FC7FCFBF311AACC242C17F318AADE449B5F8A61A1C657304D74B385D99B7A69CE957CF2D36F138A681E","length":"285","key_num":"SC-Z11051"}]';//
//print_r($longleList);
//file_put_contents ( "protected/config/longle.bak", $longleList );
$longleList=json_decode($longleList,TRUE);
// $file=isset($_POST['file'])?$_POST['file']:"";
// file_put_contents("protected/config/sites.txt",$file);
header ( 'Content-Type:text/html;charset=utf-8' );
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'锁数据不正确'),JSON_UNESCAPED_UNICODE);die;
}
//数组格式化,新增字段需要在这新增
//$longleList=$this->array_unique_update($longleList);
$serialnumber=$longleList[0]['serialnumber'];
$alloted_time=$longleList[0]['alloted_time'];
$product=$longleList[0]['product'];
$UpdateStr=$longleList[0]['UpdateStr'];
$UpdateFile='';//$longleList[0]['UpdateFile'];
$AuthorizeStr='';//$longleList[0]['AuthorizeStr'];
$AuthorizeFile='';//$longleList[0]['AuthorizeFile'];
$version=$longleList[0]['version'];
$licences=$longleList[0]['licences'];
$length=$longleList[0]['length'];
$key_num='';
if(isset($longleList[0]['key_num'])) {
$key_num=$longleList[0]['key_num'];
}
Doo::loadModel ( 'longle' );
$longle = new longle ();
if (empty($serialnumber)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息-serialnumber'),JSON_UNESCAPED_UNICODE);
die;
}
if(!empty($key_num)){
$linfo = $longle->getLongleByKeyNumDetail( $key_num,$serialnumber );
}else{
$linfo = $longle->getLongleBySerialNumber( $serialnumber );
}
//$linfo = $longle->getLongleBySerialNumber( $serialnumber );
if (empty($linfo)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息-serialnumber2'),JSON_UNESCAPED_UNICODE);
die;
}
$save_path = DOO::conf ()->SITE_PATH . "upload/longle/";
$webSite = '/upload/longle/';
$file_name = $linfo['key_num'].' - '.$serialnumber.'.' . $this->_GetFileEXT ( $_FILES ["file"] ['name'] );
if (! @move_uploaded_file ( $_FILES ["file"] ["tmp_name"], $save_path . $file_name )){
echo json_encode(array('status'=>2,'msg'=>'未找到上传文件'),JSON_UNESCAPED_UNICODE);die;
}else{
$UpdateFile = $webSite . $file_name;
}
$strFile=file_get_contents($save_path . $file_name);
$strFile=substr($strFile , 0 , $length);
file_put_contents($save_path . $file_name,$strFile);
Doo::loadModel ( 'longle_log' );
$longle_log = new longle_log ();
Doo::loadModel ( 'client' );
$clientobj = new client ();
Doo::loadModel ( "action_log" );
if ($product != ""){
$longle->product = $product;
}
$longle->statusT = "升级";
$longle_log->product = $product;
$longle_log->statusT = "升级";
$longle_log->client = $linfo ['client'];
$longle_log->clientid = $linfo ['clientid'];
$clientname = $clientobj->getOne ( array (
'where' => "cid= '" . $linfo ['clientid'] . "'",
'asArray' => TRUE
) );
// 日常行为
$action_log = new action_log ();
$action_log->action = '软件 为' . $linfo ['client'] . '(' . $clientname ['companyname'] . ')升级为' . $linfo ['key_num'] . '';
$action_log->sid = 32;
$action_log->cid = 12;
$action_log->updatetime = date ( "Y-m-d" );
$action_log->time = date ( "H:i" );
$action_log->class = $action_log->iconUpdate;
$action_log->status = 7;
$action_log->insert ();
if(!empty($alloted_time)){
$longle->alloted_time = $alloted_time;
}
if(!empty($version)){
$longle->version=$version;
}
if(!empty($licences)){
$longle->licences=$licences;
}
if(!empty($AuthorizeStr)){
$longle->AuthorizeStr=$AuthorizeStr;
}
if(!empty($AuthorizeFile)){
$longle->AuthorizeFile=$AuthorizeFile;
}
if(!empty($UpdateStr)){
$longle->UpdateStr=$UpdateStr;
}
if(!empty($UpdateFile)){
$longle->UpdateFile=$UpdateFile;
}
$longle->status = 5;
$longle->lid = $linfo['lid'];
$longle->update ();
$longle_log->lid = $linfo['lid'];
$longle_log->status = 5;
$longle_log->operator = '软件';
// 责任人
$longle_log->category = '总部';
$longle_log->dateline = date ( "Y-m-d" );
$longle_log->insert ();
echo json_encode(array('status'=>1,'msg'=>'变更成功'),JSON_UNESCAPED_UNICODE);
die;
}
function longleBySerialnumber(){
//$longleList=isset($_POST['longle'])?$_POST['longle']:'{"serialnumber":"1657000186160000"}';
$longleList=isset($_POST['longle'])?$_POST['longle']:'';
//file_put_contents ( "protected/config/longle2.bak", $longleList );
$longleList=json_decode($longleList,TRUE);
header ( 'Content-Type:text/html;charset=utf-8' );
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'JSON结构不正确'),JSON_UNESCAPED_UNICODE);die;
}
$serialnumber=$longleList['serialnumber'];
Doo::loadModel ( 'longle' );
$longle = new longle ();
$list = $longle->getLongleBySerialNumberList( $serialnumber );
if (empty($list)){
echo json_encode(array('status'=>2,'msg'=>'为找到该序列号'.$serialnumber.'相关的锁信息'),JSON_UNESCAPED_UNICODE);die;
}
header ( 'Content-Type:text/html;charset=utf-8' );
echo json_encode(array('status'=>1,'longleList'=>$list),JSON_UNESCAPED_UNICODE);die;
}
function syncLongleData(){
//$longleList='{"serialnumber":"1676000455CBB200","licences":"0","version":"","AuthorizeStr":"0C534320417574682046696C6564655C53634C6F631E00000080010000D09E2CB35293F221CD984B02D7AA32B4F193902E05D5B8A04532B2D6AB25F38EE3933ECA7199B142ABCEA8773DD467D24112C2AFFAB792EA715B72838C912DB9DE66EA4F00CEB927A21D1F83444101D70469B1DE23B0B407EB115347AA756D8C6B1D6A1E2C4C811FB538EA5C5E096C1F000D227F129F332475CCBF955811BB7BD86FCFD08F52E57508DCE48DEB808CDDA1A93D0D30825ED4844F5C0B991E4A62137FF548C508243AC59E454A6C63AEF3486A0F3F066F545F4CC71052FEE860270A59FD966877277CED6D939BEA91C104608C146BD1EDED0F6500CB3C7890E15CC1DB5976365BFE498002D4F010AF8D95CE791735B7FA0E0D62077BEAF4470A930000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","UpdateStr":"","AuthorizeFileLength":"413","UpdateFileLength":"0"}';
$longleList=isset($_POST['longle'])?$_POST['longle']:"";
file_put_contents ( "protected/config/longle.bak", $longleList );
$longleList=json_decode($longleList,TRUE);
//print_r($longleList);
header ( 'Content-Type:text/html;charset=utf-8' );
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'JSON结构不正确'),JSON_UNESCAPED_UNICODE);die;
}
//数组格式化,新增字段需要在这新增
//$longleList=$this->array_unique_sync($longleList);
//print_r($longleList);
$serialnumber=$longleList['serialnumber'];
//$alloted_time=$longleList[0]['alloted_time'];
$version=$longleList['version'];
$licences=$longleList['licences'];
$UpdateStr=$longleList['UpdateStr'];
$UpdateFile='';
$AuthorizeStr=$longleList['AuthorizeStr'];
$AuthorizeFile='';
$AuthorizeFileLength=$longleList['AuthorizeFileLength'];
$UpdateFileLength=$longleList['UpdateFileLength'];
$key_num='';
if(isset($longleList['key_num'])) {
$key_num=$longleList['key_num'];
}
//文件上传处理
Doo::loadModel ( 'longle' );
$longle = new longle ();
if (empty($serialnumber)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息-empty'),JSON_UNESCAPED_UNICODE);
die;
}
if(!empty($key_num)){
$linfo = $longle->getLongleByKeyNumDetail( $key_num,$serialnumber );
}else{
$linfo = $longle->getLongleBySerialNumber( $serialnumber );
}
if (empty($linfo)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息-serialnumber'),JSON_UNESCAPED_UNICODE);
die;
}
$save_path = DOO::conf ()->SITE_PATH . "upload/longle/";
$webSite = '/upload/longle/';
//处理注册文件
// var_dump($_FILES);
// $file_name = ' - 123.' . $this->_GetFileEXT ( $_FILES ["authorizefile"] ['name'] );
// move_uploaded_file ( $_FILES ["authorizefile"] ["tmp_name"], $save_path . $file_name );
// die;
if(!empty($AuthorizeStr)){
if(isset($_FILES ["AuthorizeFile"])){
$file_name = $linfo['key_num'].' - '.$serialnumber.'.' . $this->_GetFileEXT ( $_FILES ["AuthorizeFile"] ['name'] );
if (!@move_uploaded_file ( $_FILES ["AuthorizeFile"] ["tmp_name"], $save_path . $file_name )){
echo json_encode(array('status'=>2,'msg'=>'上传文件失败-AuthorizeFile'),JSON_UNESCAPED_UNICODE);die;
}else{
$AuthorizeFile = $webSite . $file_name;
$strFile=file_get_contents($save_path . $file_name);
$strFile=substr($strFile , 0 , $AuthorizeFileLength);
file_put_contents($save_path . $file_name,$strFile);
}
}else{
echo json_encode(array('status'=>2,'msg'=>'检查不到AuthorizeFile变量'),JSON_UNESCAPED_UNICODE);die;
}
}
//处理升级文件
if(!empty($UpdateStr)){
if(isset($_FILES ["UpdateFile"])){
$file_name = $linfo['key_num'].' - '.$serialnumber.'.' . $this->_GetFileEXT ( $_FILES ["UpdateFile"] ['name'] );
if (! @move_uploaded_file ( $_FILES ["UpdateFile"] ["tmp_name"], $save_path . $file_name )){
echo json_encode(array('status'=>2,'msg'=>'上传文件失败-UpdateFile'),JSON_UNESCAPED_UNICODE);die;
}else{
$UpdateFile = $webSite . $file_name;
$strFile=file_get_contents($save_path . $file_name);
$strFile=substr($strFile , 0 , $UpdateFileLength);
file_put_contents($save_path . $file_name,$strFile);
}
}else{
echo json_encode(array('status'=>2,'msg'=>'检查不到UpdateFile变量'),JSON_UNESCAPED_UNICODE);die;
}
}
// 日常行为
Doo::loadModel ( "action_log" );
$action_log = new action_log ();
Doo::loadModel ( 'longle_log' );
$longle_log = new longle_log ();
$mark='软件 更新';$mark2='';
if(!empty($AuthorizeStr)){
$longle->AuthorizeStr=$AuthorizeStr;
$mark.=' 注册码 ';
$mark2.=' 注册码 ';
}
if(!empty($UpdateStr)){
$longle->UpdateStr=$UpdateStr;
$mark.=' 文件 ';
$mark2.=' 文件 ';
}
$action_log->action = '软件 更新' . $linfo ['key_num'] . ' '.$mark2;
$action_log->status = 13;
$longle_log->status = 8;
$longle_log->mark =$mark;
//日常操作记录
$action_log->sid = 32;
$action_log->cid = 12;
$action_log->updatetime = date ( "Y-m-d" );
$action_log->time = date ( "H:i" );
$action_log->class = $action_log->iconLock;
$action_log->insert ();
//锁信息更新
if(!empty($version)){
$longle->version=$version;
}
if(!empty($licences)){
$longle->licences=$licences;
}
//更新序列号
/* if(!empty($key_num)){
if(!empty($serialnumber)){
$longle->SerialNumber=$serialnumber;
}
} */
if(!empty($AuthorizeFile)){
$longle->AuthorizeFile=$AuthorizeFile;
}
if(!empty($UpdateFile)){
$longle->UpdateFile=$UpdateFile;
}
$longle->lid = $linfo['lid'];
$longle->update ();
//锁操作日志
$longle_log->lid = $linfo['lid'];
$longle_log->operator = '软件';
// 责任人
$longle_log->category = '总部';
$longle_log->dateline = date ( "Y-m-d" );
$longle_log->insert ();
echo json_encode(array('status'=>1,'msg'=>'同步成功'),JSON_UNESCAPED_UNICODE);
die;
}
function alterationLongle(){
$longleList=isset($_POST['longle'])?$_POST['longle']:"";
//'[{"serialnumber":"167700074DCEA600","alloted_time":"2020/11/28","version":"年限","AuthorizeStr":"0C534320417574682046696C6564655C53634C6F631E00000080010000762C68DF17103DF2B46828FC9D0A42DE45519A93C56CECD56E6282DCD680997571E19ACFCE497650EFEC739F843033B533B1670F35975FD17A61E539821C0D5EA94C12B8AAD9E5CBDC4BE3F888F559E2210BD512284C2937140131CB7211EDEED2A59E0587A88A664D6BC5B3FD7C5834B5997DC878410103ED4B1B5C111F694EACB8EF5FB4929E8557F2BD074A25966954E3B706195763E8D553BDF64F96FE6E5B94B2AAE91C0EBC5CBD4EF298C75AB923C59C06A962B408C7473E0A9DDCA44592C88471ED273DEBDEDE4491A680D834B579CBB007838AA61FAB5F1DEC0B287C06641A7E4B95C64F69BC18B4F60C5151942473B26C51D5F08A9DA0760987E7F90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}]';//
//file_put_contents ( "protected/config/longle.bak", $longleList );
// $file=isset($_POST['file'])?$_POST['file']:"";
// file_put_contents("protected/config/sites.txt",$file);
$longleList=json_decode($longleList,TRUE);
header ( 'Content-Type:text/html;charset=utf-8' );
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'锁数据不正确'),JSON_UNESCAPED_UNICODE);die;
}
//数组格式化,新增字段需要在这新增
//$longleList=$this->array_unique_alteration($longleList);
$serialnumber=$longleList[0]['serialnumber'];
$alloted_time=$longleList[0]['alloted_time'];
$version=$longleList[0]['version'];
$UpdateStr='';//$longleList[0]['UpdateStr'];
$UpdateFile='';//$longleList[0]['UpdateFile'];
$AuthorizeStr=$longleList[0]['AuthorizeStr'];
$AuthorizeFile='';
$length=$longleList[0]['length'];
$key_num='';
if(isset($longleList[0]['key_num'])) {
$key_num=$longleList[0]['key_num'];
}
//文件上传处理
Doo::loadModel ( 'longle' );
$longle = new longle ();
if (empty($serialnumber)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息'),JSON_UNESCAPED_UNICODE);
die;
}
if(!empty($key_num)){
$linfo = $longle->getLongleByKeyNumDetail( $key_num,$serialnumber );
}else{
$linfo = $longle->getLongleBySerialNumber( $serialnumber );
}
//$linfo = $longle->getLongleBySerialNumber( $serialnumber );
if (empty($linfo)){
echo json_encode(array('status'=>2,'msg'=>'未找到该锁信息'),JSON_UNESCAPED_UNICODE);
die;
}
$save_path = DOO::conf ()->SITE_PATH . "upload/longle/";
$webSite = '/upload/longle/';
$file_name = $linfo['key_num'].' - '.$serialnumber.'.' . $this->_GetFileEXT ( $_FILES ["file"] ['name'] );
if (! @move_uploaded_file ( $_FILES ["file"] ["tmp_name"], $save_path . $file_name )){
echo json_encode(array('status'=>2,'msg'=>'未找到上传文件'),JSON_UNESCAPED_UNICODE);die;
}else{
$AuthorizeFile = $webSite . $file_name;
}
$strFile=file_get_contents($save_path . $file_name);
$strFile=substr($strFile , 0 , $length);
file_put_contents($save_path . $file_name,$strFile);
$licences='';//$longleList[0]['licences'];
/* $serialnumber = $this->get_args ( 'serialnumber' ) ? $this->get_args ( 'serialnumber' ) : "";
$alloted_time = isset($_POST['alloted_time'])?$_POST['alloted_time']:"";
//$alloted_time = $this->get_args ( 'alloted_time' ) ? $this->get_args ( 'alloted_time' ) : '';
//$status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 0;//5升级 10延期
$UpdateStr = $this->get_args ( 'UpdateStr' ) ? $this->get_args ( 'UpdateStr' ) : "";
$UpdateFile = $this->get_args ( 'UpdateFile' ) ? $this->get_args ( 'UpdateFile' ) : "";
$AuthorizeStr = $this->get_args ( 'AuthorizeStr' ) ? $this->get_args ( 'AuthorizeStr' ) : "";
$AuthorizeFile = $this->get_args ( 'AuthorizeFile' ) ? $this->get_args ( 'AuthorizeFile' ) : "";
$version = $this->get_args ( 'version' ) ? $this->get_args ( 'version' ) : "";
$licences = $this->get_args ( 'licences' ) ? $this->get_args ( 'licences' ) : ""; */
// 日常行为
Doo::loadModel ( "action_log" );
$action_log = new action_log ();
Doo::loadModel ( 'longle_log' );
$longle_log = new longle_log ();
$mark='软件 更新';$mark2='';
if(!empty($AuthorizeStr)){
$longle->AuthorizeStr=$AuthorizeStr;
$mark.=' 注册码 ';
$mark2.=' 注册码 ';
}
if(!empty($UpdateStr)){
$longle->UpdateStr=$UpdateStr;
$mark.=' 文件 ';
$mark2.=' 文件 ';
}
if(empty($version)){
$action_log->action = '软件 为' . $linfo ['key_num'] . ' 延期至 ';
$action_log->status = 12;
$longle->alloted_time = '';//更新锁延期时间
$longle->status = 10;
$longle_log->status = 10;
$longle_log->mark ='由'.$linfo['alloted_time'].'延期至 ';
/*$action_log->action = '软件 更新' . $linfo ['key_num'] . ' '.$mark2;
$action_log->status = 13;
$longle_log->status = 8;
$longle_log->mark =$mark; */
}else{
if (empty($alloted_time)){
$action_log->action = '软件 为' . $linfo ['key_num'] . ' 延期至 ';
$action_log->status = 12;
$longle->alloted_time = '';//更新锁延期时间
$longle->status = 10;
$longle_log->status = 10;
$longle_log->mark ='由'.$linfo['alloted_time'].'延期至 ';
/*
echo json_encode(array('status'=>2,'msg'=>'限制时间未接收'),JSON_UNESCAPED_UNICODE);die;
$action_log->action = '软件 更新' . $linfo ['key_num'] . ' '.$mark2;
$action_log->status = 13;
$longle_log->status = 8;
$longle_log->mark =$mark; */
}else{
$action_log->action = '软件 为' . $linfo ['key_num'] . ' 延期至'.$alloted_time;
$action_log->status = 12;
$longle->alloted_time = $alloted_time;//更新锁延期时间
$longle->status = 10;
$longle_log->status = 10;
$longle_log->mark ='由'.$linfo['alloted_time'].'延期至'.$alloted_time;
}
}
//日常操作记录
$action_log->sid = 32;
$action_log->cid = 12;
$action_log->updatetime = date ( "Y-m-d" );
$action_log->time = date ( "H:i" );
$action_log->class = $action_log->iconLock;
$action_log->insert ();
//锁信息更新
if(!empty($version)){
$longle->version=$version;
}
if(!empty($licences)){
$longle->licences=$licences;
}
if(!empty($AuthorizeFile)){
$longle->AuthorizeFile=$AuthorizeFile;
}
if(!empty($UpdateFile)){
$longle->UpdateFile=$UpdateFile;
}
$longle->lid = $linfo['lid'];
$longle->update ();
//锁操作日志
$longle_log->lid = $linfo['lid'];
$longle_log->operator = '软件';
// 责任人
$longle_log->category = '总部';
$longle_log->dateline = date ( "Y-m-d" );
$longle_log->insert ();
echo json_encode(array('status'=>1,'msg'=>'变更成功'),JSON_UNESCAPED_UNICODE);
die;
}
/**
* 获取get或者POST值
* @param string $name 属性名称
* @return fixed 值
*/
function get_args($name) {
if (isset ( $_GET [$name] )) {
if (is_array ( $_GET [$name] ))
return $_GET [$name];
else {
return addslashes ( $_GET [$name] );
}
} elseif (isset ( $_POST [$name] )) {
if (is_array ( $_POST [$name] ))
return $_POST [$name];
else {
return addslashes ( $_POST [$name] );
}
} else {
return false;
}
}
function postEmail($elid){
if (!empty($elid)){
$url = 'http://sendcloud.sohu.com/webapi/mail.send.json';
$param = array('api_user' => 'cldmail',
'api_key' => 'cDO1GjtY1seH',
'to'=>'cpthought@vip.qq.com',
'from' =>'cpthought@vip.qq.com',
'fromname' => '软件导入CLD锁接口',
'subject' => '软件导入CLD锁接口通知',
'html' => $elid);
$post_data = http_build_query($param);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, false); //设定是否输出页面内容
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result =curl_exec($ch);
curl_close($ch);
}
}
function array_unique_fb($array2D){
foreach ($array2D as $k=>$v){
$v=join(',',$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
$temp[$k]=$v;
}
$temp=array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
foreach ($temp as $k => $v){
$array=explode(',',$v); //再将拆开的数组重新组装
//下面的索引根据自己的情况进行修改即可
$temp2[$k]['key_num'] =$array[0];
$temp2[$k]['serialnumber'] =$array[1];
$temp2[$k]['product'] =$array[2];
$temp2[$k]['make_day'] =$array[3];
$temp2[$k]['alloted_time'] =$array[4];
$temp2[$k]['version'] =$array[5];
$temp2[$k]['cid'] =$array[6];
$temp2[$k]['title'] =$array[7];
$temp2[$k]['licences'] =$array[8];
$temp2[$k]['AuthorizeStr'] =$array[9];
$temp2[$k]['UpdateStr'] =$array[10];
}
return $temp2;
}
function array_unique_sync($array2D){
foreach ($array2D as $k=>$v){
$v=join(',',$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
$temp[$k]=$v;
}
$temp=array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
foreach ($temp as $k => $v){
$array=explode(',',$v); //再将拆开的数组重新组装
//下面的索引根据自己的情况进行修改即可
$temp2[$k]['serialnumber'] =$array[0];
$temp2[$k]['licences'] =$array[1];
$temp2[$k]['version'] =$array[2];
$temp2[$k]['AuthorizeStr'] =$array[3];
$temp2[$k]['UpdateStr'] =$array[4];
$temp2[$k]['AuthorizeFileLength'] =$array[5];
$temp2[$k]['UpdateFileLength'] =$array[6];
}
return $temp2;
}
function array_unique_alteration($array2D){
foreach ($array2D as $k=>$v){
$v=join(',',$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
$temp[$k]=$v;
}
$temp=array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
foreach ($temp as $k => $v){
$array=explode(',',$v); //再将拆开的数组重新组装
//下面的索引根据自己的情况进行修改即可
$temp2[$k]['serialnumber'] =$array[0];
$temp2[$k]['alloted_time'] =$array[1];
$temp2[$k]['version'] =$array[2];
$temp2[$k]['AuthorizeStr'] =$array[3];
$temp2[$k]['length'] =$array[4];
//$temp2[$k]['AuthorizeFile'] =$array[4];
}
return $temp2;
}
function array_unique_update($array2D){
foreach ($array2D as $k=>$v){
$v=join(',',$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
$temp[$k]=$v;
}
$temp=array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
foreach ($temp as $k => $v){
$array=explode(',',$v); //再将拆开的数组重新组装
//下面的索引根据自己的情况进行修改即可
$temp2[$k]['serialnumber'] =$array[0];
$temp2[$k]['product'] =$array[1];
$temp2[$k]['alloted_time'] =$array[2];
$temp2[$k]['version'] =$array[3];
$temp2[$k]['licences'] =$array[4];
$temp2[$k]['UpdateStr'] =$array[5];
$temp2[$k]['length'] =$array[6];
$temp2[$k]['key_num'] =$array[7];
}
return $temp2;
}
/**
* 格式化excel文件为数组
* @param unknown_type $file_url
* @param unknown_type $mcid
*/
function _format_excel_to_array($file_url = "") {
if (! file_exists ( $file_url ))
return array ();
Doo::loadClass ( 'PHPExcel' );
$PHPExcel = new PHPExcel ();
$PHPReader = new PHPExcel_Reader_Excel2007 ();
if (! $PHPReader->canRead ( $file_url )) {
$PHPReader = new PHPExcel_Reader_Excel5 ();
if (! $PHPReader->canRead ( $file_url )) {
echo 'no Excel';
return;
}
}
$PHPExcel = $PHPReader->load ( $file_url );
/**读取excel文件中的第一个工作表*/
$currentSheet = $PHPExcel->getSheet ( 0 );
/**取得最大的列号*/
$allColumn = $currentSheet->getHighestColumn ();
/**取得一共有多少行*/
$allRow = $currentSheet->getHighestRow ();
$excel_array = array ();
for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
$excel_column = array ();
//后期改进
if($allColumn=='AM')
$allColumn='Z';
/**从第A列开始输出*/
for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
$val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
/**ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',*/
$val = "'" . addslashes ( $val ) . "'";
if ($currentColumn == 'A')
$excel_column ['key_num'] = $val;
elseif ($currentColumn == 'C')
$excel_column ['product'] = $val;
elseif ($currentColumn == 'D'){
$val=str_replace("'","",$val);
$excel_column ['make_day'] = $this->excelTime($val);
}elseif($currentColumn == 'E'){
$val=str_replace("'","",$val);
$excel_column ['alloted_time'] = $this->excelTime($val);
}elseif($currentColumn == 'F'){
$val=str_replace("'","",$val);
$excel_column ['version'] = $val;
}elseif ($currentColumn == 'B'){
$val=str_replace("'","",$val);
$excel_column ['SerialNumber'] = $val;
}
}
array_push ( $excel_array, $excel_column );
}
return $excel_array;
}
/**
* 旧输入导入
*/
function _GetFileEXT($filename) {
$pics = explode ( '.', $filename );
$num = count ( $pics );
return $pics [$num - 1];
}
/* function updateLockApi(){
$longleList=isset($_POST['longle'])?$_POST['longle']:"";
header ( 'Content-Type:text/html;charset=utf-8' );
if($longleList!=""){
Doo::loadModel ( 'longle' );
Doo::loadModel ( 'longle_log' );
//$exlArray=$this->_format_excel_to_array(DOO::conf()->SITE_PATH."upload/".iconv("UTF-8", "GB2312", $path));
//file_put_contents ( "protected/config/longle.bak", $longleList );
$longleList=json_decode($longleList,TRUE);
if (!is_array($longleList)){
echo json_encode(array('status'=>2,'msg'=>'锁数据不正确'),JSON_UNESCAPED_UNICODE);die;
}
//数组格式化,新增字段需要在这新增
$longleList=$this->array_unique_Update($longleList);
//$category=$L_category->getCategoryById($cid);
try {
Doo::db()->beginTransaction();
foreach ($longleList as $key=>$value){
$longle = new longle ();
$detail=$longle->getLongleBySerialNumber($value['serialnumber']);
if(empty($detail)){
echo json_encode(array('status'=>2,'msg'=>'找不到相关锁信息'),JSON_UNESCAPED_UNICODE);die;
}
//锁记录
$longle = new longle ();
if(!empty($value['product'])){
$longle->product=$detail['product'].'+'.$value['product'];
}
if(!empty($value['alloted_time'])){
$longle->alloted_time=$value['alloted_time'];
}
if(!empty($value['version'])){
$longle->version=$value['version'];
}
if(!empty($value['licences'])){
$longle->licences=$value['licences'];
}
if(!empty($value['AuthorizeStr'])){
$longle->AuthorizeStr=$value['AuthorizeStr'];
}
if(!empty($value['AuthorizeFile'])){
$longle->AuthorizeFile=$value['AuthorizeFile'];
}
if(!empty($value['UpdateStr'])){
$longle->UpdateStr=$value['UpdateStr'];
}
if(!empty($value['UpdateFile'])){
$longle->UpdateFile=$value['UpdateFile'];
}
//更新方法
$longle->update ( array (
'where' => 'lid=' . $detail['lid']
) );
//锁日志记录
$longle_log=new longle_log();
$longle_log->lid=$detail['lid'];
$longle_log->status=11;
$longle_log->statusT="更新";
$longle_log->operator='软件更新锁信息';
$longle_log->product=$longle->product;
$longle_log->category='总部';
$longle_log->dateline=date("Y-m-d");
$id=$longle_log->insert();
}
//记录日常行为
Doo::loadModel("action_log");
$action_log=new action_log();
$action_log->action='总部软件更新'.$detail['key_num'].'锁';
$action_log->sid=32;
$action_log->cid=12;
$action_log->class=$action_log->iconGenerate;
$action_log->updatetime=date("Y-m-d");
$action_log->time=date("H:i");
$action_log->status=12;
$action_log->insert();
Doo::db()->commit();
} catch (Exception $e) {
echo json_encode(array('status'=>2,'msg'=>'数据更新发生异常'),JSON_UNESCAPED_UNICODE);
//print $e->getMessage();
die;
}
echo json_encode(array('status'=>1,'msg'=>'更新成功'),JSON_UNESCAPED_UNICODE);die;
}else{
echo json_encode(array('status'=>2,'msg'=>'请求参数不正确或者为空'),JSON_UNESCAPED_UNICODE);die;
}
} */
}
?>