Duplicate.php
6.6 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
<?php
namespace app\school\controller\project_approval;
use app\common\controller\DoubleBase;
use app\school\model\project_common\ProjectRegister;
use think\Db;
use think\Exception;
class Duplicate extends DoubleBase
{
protected $containerId = null;
protected $model = null;
protected $shopIdAutoCondition = false;
public function _initialize()
{
parent::_initialize();
$this->containerId = $_COOKIE['container_id'];
$this->model = new ProjectRegister();
}
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$matchInfo = Db::name('project_container')->where(['id' => $this->containerId])->find();
$rate = $matchInfo['checkagain'] == 1 ? $matchInfo['checkagain_scale'] : 100;
// 默认查询项目容器下未淘汰(|未退回)的项目
$field = [
'a.*',
't.name as project_type_name',
'u.nickname',
'u.student_no',
'c.college_name as college_name',
'd.specialty_name as major_name',
// 'SUM(r.result) as sum',
'count(member_id) as memberCount'
];
$total = $this->model
->field('a.id')
->alias('a')
->join('user u', 'a.user_id = u.id', 'left')
->join('project_type t', 'a.project_type = t.id', 'left')
->join('college c', 'u.college = c.id', 'left')
->join('specialty d', 'u.specialty = d.id', 'left')
->where(['a.container_id' => $this->containerId,'review_stage' => 0])
->where('a.repeat_rate','neq',$rate)
->count();
$list = $this->model
->field($field)
->alias('a')
->join('user u', 'a.user_id = u.id', 'left')
->join('project_type t', 'a.project_type = t.id', 'left')
->join('college c', 'u.college = c.id', 'left')
->join('fa_members m','a.id = m.item_id and member_type = 1 and member_source = 2','left')
->join('specialty d', 'u.specialty = d.id', 'left')
->where(['a.container_id' => $this->containerId,'review_stage' => 0])
->where('a.repeat_rate','neq',$rate)
->group('a.id')
->limit($offset, $limit)
->select();
foreach ($list as &$row) {
$row['project_teachers'] = json_decode($row['project_teachers'], true);
$row['repeat_rate'] = $row['repeat_rate'].'%';
if($row['project_status'] != 0) {
switch ($row['project_status'])
{
case 1:
$row['status'] = '已淘汰';
break;
case 2:
$row['status'] = '已驳回';
break;
default:
$row['status'] = '已延期';
}
}else {
switch ($row['project_approval_status'])
{
case 0:
$row['status'] = '教师未审核';
break;
case 1:
$row['status'] = '学院未审核';
break;
case 2:
$row['status'] = '学校未审核';
break;
default:
$row['status'] = '学校已审核';
}
}
}
$result = [
'total' => $total,
'rows' => $list
];
return $result;
}
return $this->view->fetch();
}
/**
* 查重审核
*/
public function editProject()
{
if ($this->request->isAjax()) {
$list = $this->request->param('list');
$list = json_decode($list, true);
$user= session("school");
$arr = [];
foreach ($list as $val) {
$tmp['id'] = $val['id'];
$tmp['project_status'] = $val['project_status'];
$arr[] = $tmp;
}
Db::startTrans();
try {
//保存审核日志
$this->register_log($list);
$this->model->allowField(true)->saveAll($arr);
Db::commit();
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success();
}
}
// 保存审核日志
private function register_log($list){
# 获取用户ID
$admin_id = $this->auth->id;
#
if(!empty($list)) {
$insertData = [];
foreach ($list as $val) {
if(isset($val['memo']) && mb_strlen($val['memo'],"UTF-8") > 200) {
$this->error("审核原因在200字以内");
}
$item = ProjectRegister::get($val['id']);
$data['register_id'] = $item['id'];
$data['container_id'] = $item['container_id'];
$data['project_college'] = $item['project_college'];
$data['project_name'] = $item['project_name'];
$data['verify_stage'] = $val['verify_stage'];
$data['memo'] = isset($val['memo']) ? $val['memo'] : '';
$data['school_id'] = $this->auth->school_id;
$data['teacher_id'] = $admin_id;
$data['teacher_name'] = $this->auth->nickname;
if($item['review_stage'] == 0) {
switch ($item['project_approval_status'])
{
case 1:
$data['type'] = 'collage';
break;
default:
$data['type'] = 'school';
}
}
$data['operation'] = '驳回';
$data['created_time'] = date('Y-m-d H:i:s',time());
$insertData[] = $data;
}
if(!empty($insertData)) {
db('register_log')->insertAll($insertData);
}
}
}
}