完善了dataservice与wsn的对接,在pdf生成中,如果有子集选择数据,则添加到附件中

This commit is contained in:
Li Jianxuan 2013-08-29 07:53:31 +00:00
parent 6152c36246
commit 7c131daf89
7 changed files with 223 additions and 156 deletions

View File

@ -1797,7 +1797,6 @@ class DataController extends Zend_Controller_Action
} elseif ($formData['submit']) { } elseif ($formData['submit']) {
//提交 //提交
//生成PDF //生成PDF
$orderListener = new OrderListener(); $orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener); @$order->events()->attachAggregate($orderListener);

View File

@ -1,146 +1,198 @@
<?php <?php
//生成西部数据中心离线申请表 //生成西部数据中心离线申请表
require_once('fpdf/chinese-unicode.php');
require_once('fpdi/fpdi.php'); use Helpers\View as view;
class ApplicantPDF extends FPDI
{ require_once('fpdf/chinese-unicode.php');
public $template;//模板文件的路径 require_once('fpdi/fpdi.php');
public $heihetemplate;//模板文件的路径 class ApplicantPDF extends FPDI
public $data;//包含具体的数据,数组 {
public $fontsize=10; public $template;//模板文件的路径
function __construct() public $heihetemplate;//模板文件的路径
{ public $data;//包含具体的数据,数组
parent::__construct(); public $fontsize=10;
$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro'); function __construct()
} {
function drawWestdc() parent::__construct();
{ $this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
$pagecount = $this->setSourceFile($this->template); }
$tplidx = $this->importPage(1); function drawWestdc()
$this->addPage(); {
$pagecount = $this->setSourceFile($this->template);
$tplidx = $this->importPage(1);
$this->addPage();
$this->useTemplate($tplidx); $this->useTemplate($tplidx);
$this->SetFont('ugb','',$this->fontsize); $this->SetFont('ugb','',$this->fontsize);
$this->setXY(74,43); $this->setXY(74,43);
$this->Write($this->fontsize,$this->data['realname']); $this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55); $this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['westdclist'])); $this->MultiCell (166, 4, str_replace(";","\n",$this->data['westdclist']));
$this->setXY(30,100); $this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project'])); $this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239); //$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']); //$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,223); $this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']); $this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,223); $this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']); $this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,223); $this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']); $this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,230); $this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']); $this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,230); $this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']); $this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d"); $t=date("Y-m-d");
$this->setXY(174,230); $this->setXY(174,230);
$this->Write($this->fontsize,$t); $this->Write($this->fontsize,$t);
} }
function drawHeihe() function drawHeihe()
{ {
$pagecount = $this->setSourceFile($this->heihetemplate); $pagecount = $this->setSourceFile($this->heihetemplate);
$tplidx = $this->importPage(1); $tplidx = $this->importPage(1);
$this->addPage(); $this->addPage();
$this->useTemplate($tplidx); $this->useTemplate($tplidx);
$this->SetFont('ugb','',$this->fontsize); $this->SetFont('ugb','',$this->fontsize);
$this->setXY(88,43); $this->setXY(88,43);
$this->Write($this->fontsize,$this->data['realname']); $this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55); $this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['heihelist'])); $this->MultiCell (166, 4, str_replace(";","\n",$this->data['heihelist']));
$this->setXY(30,100); $this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project'])); $this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239); //$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']); //$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,223); $this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']); $this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,223); $this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']); $this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,223); $this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']); $this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,230); $this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']); $this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,230); $this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']); $this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d"); $t=date("Y-m-d");
$this->setXY(174,230); $this->setXY(174,230);
$this->Write($this->fontsize,$t); $this->Write($this->fontsize,$t);
} }
function addRef($mds) function addRef($mds)
{ {
$this->addPage(); $this->addPage();
$this->SetFont('ugb','B',20); $this->SetFont('ugb','B',20);
$this->ln(); $this->ln();
$this->Cell(0,0,'附件:数据引用信息',0,2,'C'); $this->Cell(0,0,'附件:数据引用信息',0,2,'C');
$this->setY(30); $this->setY(30);
foreach($mds as $i=>$md) foreach($mds as $i=>$md)
{ {
$this->SetFont('ugb','',12); $this->SetFont('ugb','',12);
$this->Write(5,($i+1).'. '.$md['title']); $this->Write(5,($i+1).'. '.$md['title']);
$this->ln(); $this->ln();
if ($md['reference']) if ($md['reference'])
{ {
$this->Write(5,'【引用方式】'.$md['reference']); $this->Write(5,'【引用方式】'.$md['reference']);
$this->ln(); $this->ln();
if (!empty($md['publish_year'])) if (!empty($md['publish_year']))
{ {
$this->Write(5,'【数据的引用】'.substr($md['authors'],1,-1).'. '.$md['doititle'].'. '.$md['publisher'].', ' $this->Write(5,'【数据的引用】'.substr($md['authors'],1,-1).'. '.$md['doititle'].'. '.$md['publisher'].', '
.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))). .(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).
'. doi:'.$md['datadoi'].' ['.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en'] '. doi:'.$md['datadoi'].' ['.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en']
.'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi'].']'); .'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi'].']');
$this->ln(); $this->ln();
} }
} elseif ($md['citation']) } elseif ($md['citation'])
{ {
$this->Write(5,'【引用方式】'.$md['citation']); $this->Write(5,'【引用方式】'.$md['citation']);
$this->ln(); $this->ln();
if (!empty($md['publish_year']) && !strpos($md['citation'],$md['datadoi'])) if (!empty($md['publish_year']) && !strpos($md['citation'],$md['datadoi']))
{ {
$this->Write(5,'【数据的引用】'.substr($md['authors'],1,-1).'. '.$md['doititle'].'. '.$md['publisher'].', ' $this->Write(5,'【数据的引用】'.substr($md['authors'],1,-1).'. '.$md['doititle'].'. '.$md['publisher'].', '
.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))). .(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).
'. doi:'.$md['datadoi'].' ['.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en'] '. doi:'.$md['datadoi'].' ['.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en']
.'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi'].']'); .'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi'].']');
$this->ln(); $this->ln();
} }
} }
if ($md['suppinfo'] || $md['fund']) if ($md['suppinfo'] || $md['fund'])
{ {
$this->SetFont('ugb','I',10); $this->SetFont('ugb','I',10);
$p=(!empty($md['fund']))?$md['fund']:$md['suppinfo']; $p=(!empty($md['fund']))?$md['fund']:$md['suppinfo'];
$this->Write(5,'【项目信息】'.$p); $this->Write(5,'【项目信息】'.$p);
$this->ln(); $this->ln();
} }
$this->ln(); $this->ln();
} }
} }
function addSecurity($template_file) function addSecurity($template_file)
{ {
$pagecount = $this->setSourceFile($template_file); $pagecount = $this->setSourceFile($template_file);
$tplidx = $this->importPage(1); $tplidx = $this->importPage(1);
$this->addPage(); $this->addPage();
$this->useTemplate($tplidx); $this->useTemplate($tplidx);
$this->SetFont('ugb','B',14); $this->SetFont('ugb','B',14);
$this->setXY(46,51); $this->setXY(46,51);
$this->Write(10,$this->data['realname']); $this->Write(10,$this->data['realname']);
$this->SetFont('ugb','',12); $this->SetFont('ugb','',12);
$this->setXY(122,194); $this->setXY(122,194);
$this->Write(10,$this->data['realname']); $this->Write(10,$this->data['realname']);
$this->setXY(122,201); $this->setXY(122,201);
$this->Write($this->fontsize,$this->data['address']); $this->Write($this->fontsize,$this->data['address']);
$this->setXY(122,208); $this->setXY(122,208);
$this->Write($this->fontsize,$this->data['phone']); $this->Write($this->fontsize,$this->data['phone']);
$this->setXY(122,215); $this->setXY(122,215);
$this->Write($this->fontsize,$this->data['email']); $this->Write($this->fontsize,$this->data['email']);
$t=date("Y-m-d"); $t=date("Y-m-d");
$this->setXY(32,242); $this->setXY(32,242);
$this->Write($this->fontsize,$t); $this->Write($this->fontsize,$t);
$this->setXY(122,242); $this->setXY(122,242);
$this->Write($this->fontsize,$t); $this->Write($this->fontsize,$t);
} }
}
//如果有dataservice内容则添加
public function addSelection($data)
{
$line = array();
foreach($data as $k=>$v)
{
if(!empty($v['selection']))
{
$selection = json_decode($v['selection'],true);
$thisline = "".$v['title']."\r\n";
foreach($selection as $s)
{
$thisline .= "".$s['name'].": ";
if($s['var'] == -1)
{
$thisline .= "全部";
}else{
foreach($s['var'] as $var)
{
$thisline.= $var["nameview"]."/";
}
}
$thisline .= $s['starttime'] ." - ". $s['endtime'];
$thisline .= "\r\n\r\n";
}
$line[] = $thisline."";
}
}
if(count($line) < 1)
{
return;
}
$this->addPage();
$this->SetFont('ugb','B',20);
$this->ln();
$this->Cell(0,0,'附件:申请的数据子集',0,2,'C');
$this->setY(30);
foreach($line as $k=>$v)
{
$this->SetFont('ugb','',10);
$this->Write(5,($k+1).'. ' .$v ."\r\n");
$this->ln();
}
}
}
?> ?>

View File

@ -40,25 +40,32 @@ class DataService
public function getWsnData($type,$uuid = "",$param = ""){ public function getWsnData($type,$uuid = "",$param = ""){
$info = $this->get($uuid); $info = $this->get($uuid);
$curl = new Curl(); $curl = new Curl();
$uid = view::User('id');
if(!is_numeric($uid) || $uid <1)
{
return "请先登录";
}
if($type == 'site') if($type == 'site')
{ {
$param = array( $param = array(
'uuid'=>$uuid, 'uuid'=>$uuid,
//'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST //'uuid'=> 'b7beb8bf-58d9-4e58-a945-7b6e1dc7705f', ///TEST TEST TEST
'uid'=> view::User('id') 'uid'=> view::User('id')
); );
$data = $curl->request($info['service_url']."site/",$param,"POST"); $data = $curl->request($info['service_url']."site/",$param,"POST");
$data = json_decode($data['response'],TRUE); $data = json_decode($data['response'],TRUE);
}//site }//site
if($type == 'var') if($type == 'var')
{ {
$param_temp = array( $param_temp = array(
'uuid'=>$uuid, 'uuid'=>$uuid,
//'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST //'uuid'=> 'b7beb8bf-58d9-4e58-a945-7b6e1dc7705f', ///TEST TEST TEST
'uid'=> view::User('id'), 'uid'=> view::User('id'),
); );
$param = array_merge($param,$param_temp); $param = array_merge($param,$param_temp);
@ -69,11 +76,12 @@ class DataService
if($type == 'submit') if($type == 'submit')
{ {
$param_temp = array( $param_temp = array(
'uuid'=>$uuid, //'uuid'=>$uuid,
//'uuid'=> '78e2423f-fe4a-4f9e-a368-c932afc5d257', ///TEST TEST TEST 'uuid'=> 'b7beb8bf-58d9-4e58-a945-7b6e1dc7705f', ///TEST TEST TEST
'uid'=> view::User('id'), 'uid'=> view::User('id'),
); );
$param = array_merge($param,$param_temp); $param = array_merge($param,$param_temp);
$data = $curl->request($info['service_url']."insert/",$param,"POST"); $data = $curl->request($info['service_url']."insert/",$param,"POST");
$data = json_decode($data['response'],TRUE); $data = json_decode($data['response'],TRUE);
} }

View File

@ -308,6 +308,7 @@ class Order
if (isset($formData['heihelist'])) $pdf->drawHeihe(); if (isset($formData['heihelist'])) $pdf->drawHeihe();
$pdf->addRef($this->pdfData); $pdf->addRef($this->pdfData);
$pdf->addSelection($this->pdfData);
$pdf->addSecurity($this->config->offline->security); $pdf->addSecurity($this->config->offline->security);
@ -338,7 +339,7 @@ class Order
$uid = view::User('id'); $uid = view::User('id');
} }
$sql = "select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo, $sql = "select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,d.selection,
array_to_string(ARRAY( array_to_string(ARRAY(
select r.reference from mdref mr left join reference r on mr.refid=r.id select r.reference from mdref mr left join reference r on mr.refid=r.id
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference, where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,

View File

@ -46,9 +46,12 @@ class PdfOperate implements \Order\listener\PdfEvents
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
$formData['username'] = $formData['realname']; $formData['username'] = $formData['realname'];
$formData['userid'] = $uid;
unset($formData['realname']); unset($formData['realname']);
unset($formData['save']); unset($formData['save']);
unset($formData['submit']); unset($formData['submit']);
unset($formData['id']);
if ($row) { if ($row) {
$s = $dbh->update($this->tbl_offlineapp,$formData," id={$row['id']} "); $s = $dbh->update($this->tbl_offlineapp,$formData," id={$row['id']} ");
@ -60,9 +63,14 @@ class PdfOperate implements \Order\listener\PdfEvents
} }
} else { } else {
if(empty($returnid)) if(empty($returnid))
{ {
$s = $dbh->insert($this->tbl_offlineapp,$formData); $s = $dbh->insert($this->tbl_offlineapp,$formData);
return $s; if($s > 0)
{
return true;
}else{
return "保存失败,请重试";
}
}else{ }else{
$id = $dbh->insert($this->tbl_offlineapp,$formData,true); $id = $dbh->insert($this->tbl_offlineapp,$formData,true);
return $id; return $id;

View File

@ -220,9 +220,9 @@ westdc.dataservice.wsn = {
$(this).find('.wsnctl-select-all').click(function(e) { $(this).find('.wsnctl-select-all').click(function(e) {
if($(this).attr('checked') == 'checked') if($(this).attr('checked') == 'checked')
{ {
_this.find('.wsnctl-select').attr('disabled','disabled'); $(this).parent('label').parent('div').find('.wsnctl-select').attr('disabled','disabled');
}else{ }else{
_this.find('.wsnctl-select').removeAttr('disabled'); $(this).parent('label').parent('div').find('.wsnctl-select').removeAttr('disabled');
} }
}); });
}); });

View File

@ -329,7 +329,6 @@ function setRectangle(east,west,south,north){
map: map, map: map,
}); });
markers.push(marker);
} }
var bounds = new google.maps.LatLngBounds(); var bounds = new google.maps.LatLngBounds();