InstallController.class.php
9.09 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
/**
* 套件应用安装初始化数据
* 问卷
*
* @author zhoutao
* @date 2017-09-27 10:05:30
*/
namespace Rpc\Controller\Common;
use Common\Common\User;
use Common\Service\BaseinfoService;
use Common\Service\ClassifyService;
use Common\Service\QuestionService;
use Think\Exception;
class InstallController extends AbstractController
{
// 免登录
protected $_require_login = false;
/** @var ClassifyService */
protected $class_s;
/** @var BaseinfoService */
protected $base_info_s;
/** @var QuestionService */
protected $question_s;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化调研分类Service
$this->class_s = new ClassifyService();
// 实例化调研基础信息Service
$this->base_info_s = new BaseinfoService();
// 实例化调研问题Service
$this->question_s = new QuestionService();
return true;
}
public function Index()
{
// 查询是否存在默认分类
$count = $this->class_s->count_by_conds(['is_system' => 1]);
// 不存在默认分类
if (!$count) {
// 默认分类数据
$default_class = [
[
'qc_name' => '默认分类',
'is_system' => 1
],
[
'qc_name' => '培训需求调研',
'is_system' => 0
],
[
'qc_name' => '公司民意调查',
'is_system' => 0
],
[
'qc_name' => '意见征集',
'is_system' => 0
]
];
$this->class_s->insert_all($default_class);
// 安装默认数据
$this->default_data_install();
}
return true;
}
/**
* 默认数据安装
*
* @return bool
*/
private function default_data_install()
{
// 已有调研数
$base_info_count = $this->base_info_s->count();
// 无调研数据
if (!$base_info_count) {
// 实例化用户类
$user_s = &User::instance();
// 全部人员
$result = $user_s->listByConds([]);
// 全部人数(应参与总人数)
$involved_total = $result['total'];
// 获取培训需求调研的分类信息
$class_info = $this->class_s->get_by_conds(['qc_name' => '培训需求调研']);
try {
$this->base_info_s->start_trans();
// 组装调研基本信息数据
$add_base_info = [
'qu_type' => 1, // 常规类型
'title' => '【系统预设】企业培训情况调研',
'introduce' => '本次调研旨在了解企业的基础培训信息,帮助企业搭建优质的培训实施系统,更好的实现员工赋能,提高员工战斗力。',
'qc_id' => $class_info['qc_id'],
'deadline' => 1917014400000, // [2030/10/01 00:00]
'secret' => 1, // 保密开启
'share' => 0, // 不可分享
'is_all' => 1, // 全公司
'anonymous' => 1, // 实名
'involved_total' => $involved_total, // 全部人数(应参与总人数)
'release_time' => MILLI_TIME, // 发布时间
'release_status' => 3, // 发布状态:发布
'integral_action_type' => 1, // 积分策略:启用默认
'integral_action_type' => 1, // 积分策略:启用默认
'updated' => MILLI_TIME // 最后更新时间
];
// 写入调研基本信息默认数据
$qu_id = $this->base_info_s->insert($add_base_info);
// 组装调研问题默认数据
$add_questions = [
[
'qu_id' => $qu_id,
'q_title' => '对于业务知识的掌握情况?',
'q_type' => 1, // 单选
'q_order' => 1,
'q_required' => 1, // 必填
'q_min' => 0,
'q_max' => 0,
'q_other' => 0, // 不包含其他选项
'q_other_title' => '',
'q_field' => serialize([
['option' => '很好', 'is_check' => 0, 'img_options' => []],
['option' => '一般', 'is_check' => 0, 'img_options' => []],
['option' => '较差', 'is_check' => 0, 'img_options' => []],
]),
],
[
'qu_id' => $qu_id,
'q_title' => '对于自己工作中的执行力是否满意?',
'q_type' => 1,
'q_order' => 2,
'q_required' => 1,
'q_min' => 0,
'q_max' => 0,
'q_other' => 0,
'q_other_title' => '',
'q_field' => serialize([
['option' => '很好', 'is_check' => 0, 'img_options' => []],
['option' => '一般', 'is_check' => 0, 'img_options' => []],
['option' => '较差', 'is_check' => 0, 'img_options' => []],
]),
],
[
'qu_id' => $qu_id,
'q_title' => '对于自己的沟通能力是否满意?',
'q_type' => 1,
'q_order' => 3,
'q_required' => 1,
'q_min' => 0,
'q_max' => 0,
'q_other' => 0,
'q_other_title' => '',
'q_field' => serialize([
['option' => '很好', 'is_check' => 0, 'img_options' => []],
['option' => '一般', 'is_check' => 0, 'img_options' => []],
['option' => '较差', 'is_check' => 0, 'img_options' => []],
]),
],
[
'qu_id' => $qu_id,
'q_title' => '对于公司组织的员工培训是否满意?',
'q_type' => 1,
'q_order' => 4,
'q_required' => 1,
'q_min' => 0,
'q_max' => 0,
'q_other' => 1, // 包含其他选项
'q_other_title' => '其它',
'q_field' => serialize([
['option' => '很好', 'is_check' => 0, 'img_options' => []],
['option' => '一般', 'is_check' => 0, 'img_options' => []],
['option' => '较差', 'is_check' => 0, 'img_options' => []],
]),
],
[
'qu_id' => $qu_id,
'q_title' => '对于哪一种培训方式最认可?',
'q_type' => 2, // 多选
'q_order' => 5,
'q_required' => 1,
'q_min' => 2,
'q_max' => 5,
'q_other' => 1,
'q_other_title' => '其它',
'q_field' => serialize([
['option' => ' 线下封闭培训', 'is_check' => 0, 'img_options' => []],
['option' => '线上移动化视频/语音学习', 'is_check' => 0, 'img_options' => []],
['option' => '提供资料,自学成才', 'is_check' => 0, 'img_options' => []],
['option' => '工作导师一对一指导', 'is_check' => 0, 'img_options' => []],
]),
],
[
'qu_id' => $qu_id,
'q_title' => '对于培训方式,培训内容有哪些好的建议?',
'q_type' => 5, // 多行文本
'q_order' => 6,
'q_required' => 1,
'q_min' => 0,
'q_max' => 0,
'q_other' => 0,
'q_other_title' => '',
'q_field' => '',
],
];
// 写入调研问题默认数据
$this->question_s->insert_all($add_questions);
$this->base_info_s->commit();
} catch (Exception $e) {
// 回滚数据
$this->base_info_s->rollback();
}
}
return true;
}
}