ProjectResult.php
7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
namespace app\school\controller\project_conclusion;
use app\common\controller\DoubleBase;
use app\school\model\project_common\ProjectResult as ProjectResultClass;
use think\Db;
class ProjectResult extends DoubleBase
{
protected $containerId = null;
protected $model = null;
protected $shopIdAutoCondition = false;
public function _initialize()
{
parent::_initialize();
$this->containerId = $_COOKIE['container_id'];
$this->model = new ProjectResultClass();
}
public function index() {
return $this->view->fetch();
}
/**
* 根据成果类型,返回项目成果数据
* @return array
*/
public function data()
{
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$resultType = $this->request->param('result_type');
// $dataWhere = ['project_container_id' => $this->containerId, 'result_type' => $resultType];
// $total = $this->model->where($where)->where($dataWhere)->count();
// $rows = $this->model->where($where)->where($dataWhere)->limit($offset, $limit)->select();
switch ($resultType){
case 'winning':
$res = $this->getWinning();
break;
case 'paper':
$res = $this->getPaper();
break;
case 'patent':
$res = $this->getPatent();
break;
case 'copyright':
$res = $this->getCopyright();
break;
case 'physical':
$res = $this->getPhysical();
break;
}
// todo
// 需要将rows里的result_data字段从json转换为数组,并与row合并
// $res = [
// 'total' => $total,
// 'rows' => $rows
// ];
return $res;
}
}
/**
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* 竞赛获奖情况
*/
public function getWinning(){
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$dataWhere = ['container_id' => $this->containerId];
$total = Db::name("project_competition")->where($where)->where($dataWhere)->count();
$rows = Db::name("project_competition")->where($where)->where($dataWhere)->limit($offset, $limit)->select();
foreach ($rows as $k=>$v){
$v['id'] = $v['competition_id'];
$v['students'] = json_decode($v['student_json'],true);
$v['project_name'] = Db::name('project_register')->where('id',$v["regiter_id"])->value("project_name");
$v['reward_date'] = date("Y-m-d",$v['reward_date']);
$rows[$k] = $v;
}
return [
'total' => $total,
'rows' => $rows
];
}
/**
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* 论文发表情况
*/
public function getPaper(){
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$dataWhere = ['container_id' => $this->containerId];
$total = Db::name("project_paper")->where($where)->where($dataWhere)->count();
$rows = Db::name("project_paper")->where($where)->where($dataWhere)->limit($offset, $limit)->select();
foreach ($rows as $k=>$v){
$v['id'] = $v['paper_id'];
$v['member_json'] = json_decode($v['member_json'],true);
$v['project_name'] = Db::name('project_register')->where('id',$v["regiter_id"])->value("project_name");
$v['publish_time'] = date("Y-m-d",$v['publish_time']);
$rows[$k] = $v;
}
return [
'total' => $total,
'rows' => $rows
];
}
/**
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* 申请专利
*/
public function getPatent(){
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$dataWhere = ['container_id' => $this->containerId];
$total = Db::name("project_patent")->where($where)->where($dataWhere)->count();
$rows = Db::name("project_patent")->where($where)->where($dataWhere)->limit($offset, $limit)->select();
foreach ($rows as $k=>$v){
$v['id'] = $v['patent_id'];
$v['applicant_json'] = json_decode($v['applicant_json'],true);
$v['project_name'] = Db::name('project_register')->where('id',$v["regiter_id"])->value("project_name");
$v['patent_date'] = date("Y-m-d",$v['patent_date']);
$v['grant_date'] = date("Y-m-d",$v['grant_date']);
$rows[$k] = $v;
}
return [
'total' => $total,
'rows' => $rows
];
}
/**
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* 申请著作权情况
*/
public function getCopyright(){
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$dataWhere = ['container_id' => $this->containerId];
$total = Db::name("project_copyright")->where($where)->where($dataWhere)->count();
$rows = Db::name("project_copyright")->where($where)->where($dataWhere)->limit($offset, $limit)->select();
foreach ($rows as $k=>$v){
$v['id'] = $v['copyright_id'];
$v['applicant_json'] = json_decode($v['applicant_json'],true);
$v['project_name'] = Db::name('project_register')->where('id',$v["regiter_id"])->value("project_name");
$v['registration_date'] = date("Y-m-d",$v['registration_date']);
$rows[$k] = $v;
}
return [
'total' => $total,
'rows' => $rows
];
}
/**
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* 实物制作情况
*/
public function getPhysical(){
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$dataWhere = ['container_id' => $this->containerId];
$total = Db::name("project_production")->where($where)->where($dataWhere)->count();
$rows = Db::name("project_production")->where($where)->where($dataWhere)->limit($offset, $limit)->select();
foreach ($rows as $k=>$v){
$v['id'] = $v['production_id'];
$v['project_name'] = Db::name('project_register')->where('id',$v["regiter_id"])->value("project_name");
$rows[$k] = $v;
}
return [
'total' => $total,
'rows' => $rows
];
}
}