|
@@ -12,6 +12,7 @@ use think\Db; |
|
@@ -12,6 +12,7 @@ use think\Db; |
12
|
use think\Validate;
|
12
|
use think\Validate;
|
13
|
use cmf\controller\RestBaseController;
|
13
|
use cmf\controller\RestBaseController;
|
14
|
use app\portal\model\ExerciseModel;
|
14
|
use app\portal\model\ExerciseModel;
|
|
|
15
|
+use app\portal\model\ConfirmImageModel;
|
15
|
/**
|
16
|
/**
|
16
|
* @title 演习
|
17
|
* @title 演习
|
17
|
*/
|
18
|
*/
|
|
@@ -29,16 +30,16 @@ class ExerciseController extends RestBaseController |
|
@@ -29,16 +30,16 @@ class ExerciseController extends RestBaseController |
29
|
*
|
30
|
*
|
30
|
* @param name:page type:inter require:1 default: other desc:分页页码
|
31
|
* @param name:page type:inter require:1 default: other desc:分页页码
|
31
|
* @param name:project_id type:inter require:1 default: other desc:项目id
|
32
|
* @param name:project_id type:inter require:1 default: other desc:项目id
|
32
|
- * @param name:status type:inter require:1 default: other desc:切换状态(-1:全部,1:待领导确认(乙方领导(确认,驳回)),2:进行中,3:已完成)
|
33
|
+ * @param name:status type:inter require:1 default: other desc:切换状态(-1:全部 0:待确认,1:进行中,2:已完成)
|
33
|
* @return data:演习列表@
|
34
|
* @return data:演习列表@
|
34
|
- * @data id:演习id uid:甲方提交人id status:培训状态(0:甲方提交申请,1:乙方领导驳回,2:乙方领导确认,3:完成 ) user_login:甲方发起人 b_leader:乙方确认领导 project_name:项目名称 exercise_time:演习时间 address:演习地点
|
35
|
+ * @data id:演习id uid:甲方提交人id status:培训状态(0:待乙方确认,1:进行中,2:已完成 ) user_login:甲方发起人 b_staff:乙方确认员工 project_name:项目名称 exercise_time:演习时间 address:演习地点 confirm:是否有确认按钮(0:无,1:有) finish:是否有确认完成按钮(0:无,1:有)
|
35
|
* @return page:当前页数
|
36
|
* @return page:当前页数
|
36
|
* @return total_page:总页数
|
37
|
* @return total_page:总页数
|
37
|
*/
|
38
|
*/
|
38
|
public function exerciseList(){
|
39
|
public function exerciseList(){
|
39
|
if($this->request->isGet()){
|
40
|
if($this->request->isGet()){
|
40
|
$page = $this->request->get('page');
|
41
|
$page = $this->request->get('page');
|
41
|
- $status = $this->request->get('status');//切换状态(-1:全部,1:待领导确认(-1:全部,1:待领导确认(乙方领导(确认,驳回)),2:进行中,3:已完成)
|
42
|
+ $status = $this->request->get('status');//切换状态(-1:全部,0:待确认,1:进行中,2:已完成)
|
42
|
$project_id = $this->request->get('project_id');
|
43
|
$project_id = $this->request->get('project_id');
|
43
|
|
44
|
|
44
|
$limit = config('site.limit');
|
45
|
$limit = config('site.limit');
|
|
@@ -47,24 +48,18 @@ class ExerciseController extends RestBaseController |
|
@@ -47,24 +48,18 @@ class ExerciseController extends RestBaseController |
47
|
if (!$validate->check(['page'=>$page,'status'=>$status,'project_id'=>$project_id])) {
|
48
|
if (!$validate->check(['page'=>$page,'status'=>$status,'project_id'=>$project_id])) {
|
48
|
$this->error($validate->getError());
|
49
|
$this->error($validate->getError());
|
49
|
}
|
50
|
}
|
50
|
- //显示甲方发起人,乙方确认领导,项目名称,培训演习时间
|
51
|
+
|
51
|
$common = new CommonController();
|
52
|
$common = new CommonController();
|
52
|
- $project = $common->getUserIdentity();
|
|
|
53
|
- //如果不是甲乙方员工,则没有权限操作
|
|
|
54
|
- if($project['identity'] != config('site.a_staff') && $project['identity'] != config('site.b_staff')){
|
|
|
55
|
- $this->error('无权操作');
|
|
|
56
|
- }
|
|
|
57
|
- if($status == 1){
|
|
|
58
|
- $where = ['project_id' => $project_id, 'status' => 0];
|
|
|
59
|
- }else if($status == 2 || $status == 3){
|
|
|
60
|
- $where = ['project_id' => $project_id, 'status' => $status];
|
|
|
61
|
- }else{
|
53
|
+ if($status == -1){
|
62
|
$where = ['project_id' => $project_id];
|
54
|
$where = ['project_id' => $project_id];
|
|
|
55
|
+ }else{
|
|
|
56
|
+ $where = ['project_id' => $project_id, 'status' => $status];
|
63
|
}
|
57
|
}
|
|
|
58
|
+
|
64
|
$res = Db::name('exercise')
|
59
|
$res = Db::name('exercise')
|
65
|
->where($where)
|
60
|
->where($where)
|
66
|
->page($page,$limit)
|
61
|
->page($page,$limit)
|
67
|
- ->field('id,uid,status,b_leader,exercise_time,address')
|
62
|
+ ->field('id,uid,status,h_uid,exercise_time,address,confirm_uid')
|
68
|
->order('id desc')
|
63
|
->order('id desc')
|
69
|
->select()
|
64
|
->select()
|
70
|
->toArray();
|
65
|
->toArray();
|
|
@@ -77,9 +72,29 @@ class ExerciseController extends RestBaseController |
|
@@ -77,9 +72,29 @@ class ExerciseController extends RestBaseController |
77
|
$user = $common->getUserById(['id'=>$value['uid']]);
|
72
|
$user = $common->getUserById(['id'=>$value['uid']]);
|
78
|
$value['user_login'] = isset($user['user_login'])&&!empty($user['user_login'])?$user['user_login']:'';
|
73
|
$value['user_login'] = isset($user['user_login'])&&!empty($user['user_login'])?$user['user_login']:'';
|
79
|
|
74
|
|
80
|
- //查看乙方确认领导
|
|
|
81
|
- $leader = $common->getUserById(['id'=>$value['b_leader']]);
|
|
|
82
|
- $value['b_leader'] = isset($leader['user_login'])&&!empty($leader['user_login'])?$leader['user_login']:'';
|
75
|
+ //是否有确认按钮
|
|
|
76
|
+ $value['confirm'] = 0;
|
|
|
77
|
+ if($value['status'] == 0 && $value['h_uid'] == $this->userId){
|
|
|
78
|
+ $value['confirm'] = 1;
|
|
|
79
|
+ }
|
|
|
80
|
+ //是否有确认完成按钮
|
|
|
81
|
+ $value['finish'] = 0;
|
|
|
82
|
+ if($value['status'] == 1){
|
|
|
83
|
+ if($value['h_uid'] == $this->userId && empty($value['confirm'])){
|
|
|
84
|
+ $value['finish'] = 1;
|
|
|
85
|
+ }else{
|
|
|
86
|
+ $u_ids = $common->getUnFinishUid(['type'=>0,'c_id'=>$value['id'],'is_image'=>1]);
|
|
|
87
|
+ if(in_array($this->userId,$u_ids)){
|
|
|
88
|
+ $value['finish'] = 1;
|
|
|
89
|
+ }else{
|
|
|
90
|
+ $value['finish'] = 0;
|
|
|
91
|
+ }
|
|
|
92
|
+ }
|
|
|
93
|
+ }
|
|
|
94
|
+
|
|
|
95
|
+ //查看乙方确认员工
|
|
|
96
|
+ $staff = $common->getUserById(['id'=>$value['h_uid']]);
|
|
|
97
|
+ $value['b_staff'] = isset($staff['user_login'])&&!empty($staff['user_login'])?$staff['user_login']:'';
|
83
|
$value['project_name'] = $project_name['project_name'];
|
98
|
$value['project_name'] = $project_name['project_name'];
|
84
|
}
|
99
|
}
|
85
|
$this->success('成功',['data'=>$res,'page'=>intval($page),'total_page'=>$total_page]);
|
100
|
$this->success('成功',['data'=>$res,'page'=>intval($page),'total_page'=>$total_page]);
|
|
@@ -97,10 +112,12 @@ class ExerciseController extends RestBaseController |
|
@@ -97,10 +112,12 @@ class ExerciseController extends RestBaseController |
97
|
*
|
112
|
*
|
98
|
* @header name:token require:1 default: desc:header
|
113
|
* @header name:token require:1 default: desc:header
|
99
|
*
|
114
|
*
|
|
|
115
|
+ * @param name:title type:string require:1 default: other desc:表头信息
|
100
|
* @param name:exercise_time type:int require:1 default: other desc:演习时间
|
116
|
* @param name:exercise_time type:int require:1 default: other desc:演习时间
|
101
|
* @param name:project_id type:int require:1 default: other desc:项目id
|
117
|
* @param name:project_id type:int require:1 default: other desc:项目id
|
102
|
* @param name:address type:string require:1 default: other desc:演习地点
|
118
|
* @param name:address type:string require:1 default: other desc:演习地点
|
103
|
* @param name:remark type:string require:1 default: other desc:演习备注
|
119
|
* @param name:remark type:string require:1 default: other desc:演习备注
|
|
|
120
|
+ * @param name:u_id type:inter require:1 default: other desc:指派乙方员工id
|
104
|
*/
|
121
|
*/
|
105
|
public function applyExercise(){
|
122
|
public function applyExercise(){
|
106
|
if($this->request->isPost()){
|
123
|
if($this->request->isPost()){
|
|
@@ -119,12 +136,17 @@ class ExerciseController extends RestBaseController |
|
@@ -119,12 +136,17 @@ class ExerciseController extends RestBaseController |
119
|
$data['uid'] = $this->userId;
|
136
|
$data['uid'] = $this->userId;
|
120
|
$data['create_time'] = time();
|
137
|
$data['create_time'] = time();
|
121
|
$data['number'] = $common->genOrderSn();
|
138
|
$data['number'] = $common->genOrderSn();
|
|
|
139
|
+
|
|
|
140
|
+ //指派乙方人员uid
|
|
|
141
|
+ $data['h_uid'] = $data['u_id'];
|
|
|
142
|
+ unset($data['u_id']);
|
|
|
143
|
+
|
122
|
$exerciseModel = new ExerciseModel();
|
144
|
$exerciseModel = new ExerciseModel();
|
123
|
$res = $exerciseModel->create($data);
|
145
|
$res = $exerciseModel->create($data);
|
124
|
if($res){
|
146
|
if($res){
|
125
|
//极光推送
|
147
|
//极光推送
|
126
|
- //甲方发起,提醒乙方领导
|
|
|
127
|
- $user_ids = $common->getLeaderA($data['project_id'],'b_cid');
|
148
|
+ //甲方发起,提醒指派乙方员工
|
|
|
149
|
+ $user_ids = [$data['h_uid']];
|
128
|
$content = config('site.exercise_content_add_a');
|
150
|
$content = config('site.exercise_content_add_a');
|
129
|
|
151
|
|
130
|
$registration_id = $common->getPushUsers($user_ids);
|
152
|
$registration_id = $common->getPushUsers($user_ids);
|
|
@@ -134,6 +156,11 @@ class ExerciseController extends RestBaseController |
|
@@ -134,6 +156,11 @@ class ExerciseController extends RestBaseController |
134
|
$common->pushMessage($registration_id,$content,$title);
|
156
|
$common->pushMessage($registration_id,$content,$title);
|
135
|
}
|
157
|
}
|
136
|
|
158
|
|
|
|
159
|
+ //记录参与人员id
|
|
|
160
|
+ $join_uid['project_id'] = $data['project_id'];
|
|
|
161
|
+ $join_uid['create_time'] = $data['create_time'];
|
|
|
162
|
+ $common->createInsUid($join_uid,6);
|
|
|
163
|
+
|
137
|
$this->success('演习信息提交成功');
|
164
|
$this->success('演习信息提交成功');
|
138
|
}else{
|
165
|
}else{
|
139
|
$this->error('失败');
|
166
|
$this->error('失败');
|
|
@@ -144,80 +171,37 @@ class ExerciseController extends RestBaseController |
|
@@ -144,80 +171,37 @@ class ExerciseController extends RestBaseController |
144
|
}
|
171
|
}
|
145
|
|
172
|
|
146
|
/**
|
173
|
/**
|
147
|
- * @title 甲方重新发起申请显示(被驳回)
|
174
|
+ * @title 乙方演习确认
|
148
|
* @description 接口说明
|
175
|
* @description 接口说明
|
149
|
* @author 开发者
|
176
|
* @author 开发者
|
150
|
- * @url /api/home/exercise/reEditExercise
|
177
|
+ * @url /api/home/exercise/confirmB
|
151
|
* @method GET
|
178
|
* @method GET
|
152
|
*
|
179
|
*
|
153
|
* @header name:token require:1 default: desc:header
|
180
|
* @header name:token require:1 default: desc:header
|
154
|
*
|
181
|
*
|
155
|
- * @param name:id type:inter require:1 default: other desc:月检id
|
|
|
156
|
-
|
|
|
157
|
- * @return id:演习列表id
|
|
|
158
|
- * @return exercise_time:演习时间
|
|
|
159
|
- * @return address:演习地点
|
|
|
160
|
- * @return remark:演习备注
|
|
|
161
|
- * @return advice_time:驳回建议时间
|
182
|
+ * @param name:id type:inter require:1 default: other desc:演习id
|
162
|
*/
|
183
|
*/
|
163
|
- public function reEditExercise(){
|
184
|
+ public function confirmB(){
|
164
|
if($this->request->isGet()){
|
185
|
if($this->request->isGet()){
|
165
|
- $id = $this->request->get('id');
|
186
|
+ $id = $this->request->get('id');//演习列表id
|
|
|
187
|
+
|
166
|
$rule = config('site.data');
|
188
|
$rule = config('site.data');
|
167
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
189
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
168
|
if (!$validate->check(['id'=>$id])) {
|
190
|
if (!$validate->check(['id'=>$id])) {
|
169
|
$this->error($validate->getError());
|
191
|
$this->error($validate->getError());
|
170
|
}
|
192
|
}
|
171
|
$common = new CommonController();
|
193
|
$common = new CommonController();
|
172
|
- $field = 'id,exercise_time,address,remark,advice_time';
|
|
|
173
|
- $res = $common->getExerciseById(['id'=>$id,'status'=>1],$field);
|
|
|
174
|
- $this->success('成功',$res);
|
|
|
175
|
- }else{
|
|
|
176
|
- $this->error('请求方式错误!');
|
|
|
177
|
- }
|
|
|
178
|
- }
|
|
|
179
|
-
|
|
|
180
|
- /**
|
|
|
181
|
- * @title 甲方重新发起申请提交(被驳回)
|
|
|
182
|
- * @description 接口说明
|
|
|
183
|
- * @author 开发者
|
|
|
184
|
- * @url /api/home/exercise/reApplyExercise
|
|
|
185
|
- * @method POST
|
|
|
186
|
- *
|
|
|
187
|
- * @header name:token require:1 default: desc:header
|
|
|
188
|
- *
|
|
|
189
|
- * @param name:id type:int require:1 default: other desc:演习id
|
|
|
190
|
- * @param name:exercise_time type:int require:1 default: other desc:演习时间
|
|
|
191
|
- * @param name:address type:string require:1 default: other desc:演习地点
|
|
|
192
|
- * @param name:remark type:string require:1 default: other desc:演习备注
|
|
|
193
|
- */
|
|
|
194
|
- public function reApplyExercise(){
|
|
|
195
|
- if($this->request->isPost()){
|
|
|
196
|
- $data = $this->request->post();
|
|
|
197
|
- $common = new CommonController();
|
|
|
198
|
$user = $common->getIdentity();
|
194
|
$user = $common->getIdentity();
|
199
|
- //如果是乙方,则没有权限操作
|
|
|
200
|
- if($user['party'] == 1){
|
195
|
+ //如果是甲方,则没有权限操作
|
|
|
196
|
+ if($user['party'] == 0){
|
201
|
$this->error('无权操作');
|
197
|
$this->error('无权操作');
|
202
|
}
|
198
|
}
|
203
|
- $rule = config('site.re_exercise_post');
|
|
|
204
|
- $validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
205
|
- if (!$validate->check($data)) {
|
|
|
206
|
- $this->error($validate->getError());
|
|
|
207
|
- }
|
|
|
208
|
- $arr['uid'] = $this->userId;
|
|
|
209
|
- $arr['status'] = 0;
|
|
|
210
|
- $arr['exercise_time'] = $data['exercise_time'];
|
|
|
211
|
- $arr['address'] = $data['address'];
|
|
|
212
|
- $arr['remark'] = $data['remark'];
|
|
|
213
|
$exerciseModel = new ExerciseModel();
|
199
|
$exerciseModel = new ExerciseModel();
|
214
|
- $res = $exerciseModel->where(['id'=>$data['id'],'status'=>1])->update($arr);
|
200
|
+ $res = $exerciseModel->where(['id'=>$id,'status'=>0])->update(['status'=>1,'b_confirm_time'=>time()]);
|
215
|
if($res){
|
201
|
if($res){
|
216
|
- //极光推送
|
|
|
217
|
- //甲方重新发起,提醒乙方领导
|
|
|
218
|
- $project = $common->getProjectId('exercise',['id'=>$data['id']],'id,project_id');
|
|
|
219
|
- $user_ids = $common->getLeaderA($project['project_id'],'b_cid');
|
|
|
220
|
- $content = config('site.train_content_again_a');
|
202
|
+ //极光推送,推送发起甲方员工
|
|
|
203
|
+ $user_ids = $common->getLaunchUid('exercise',$id);
|
|
|
204
|
+ $content = config('site.exercise_content_confirm_a');
|
221
|
|
205
|
|
222
|
$registration_id = $common->getPushUsers($user_ids);
|
206
|
$registration_id = $common->getPushUsers($user_ids);
|
223
|
if($registration_id){
|
207
|
if($registration_id){
|
|
@@ -226,8 +210,7 @@ class ExerciseController extends RestBaseController |
|
@@ -226,8 +210,7 @@ class ExerciseController extends RestBaseController |
226
|
$common->pushMessage($registration_id,$content,$title);
|
210
|
$common->pushMessage($registration_id,$content,$title);
|
227
|
}
|
211
|
}
|
228
|
|
212
|
|
229
|
-
|
|
|
230
|
- $this->success('演习信息重新提交成功');
|
213
|
+ $this->success('成功!');
|
231
|
}else{
|
214
|
}else{
|
232
|
$this->error('失败');
|
215
|
$this->error('失败');
|
233
|
}
|
216
|
}
|
|
@@ -247,6 +230,7 @@ class ExerciseController extends RestBaseController |
|
@@ -247,6 +230,7 @@ class ExerciseController extends RestBaseController |
247
|
* @param name:id type:inter require:1 default: other desc:列表id
|
230
|
* @param name:id type:inter require:1 default: other desc:列表id
|
248
|
*
|
231
|
*
|
249
|
* @return id:演习列表id
|
232
|
* @return id:演习列表id
|
|
|
233
|
+ * @return title:培训表头信息
|
250
|
* @return exercise_time:演习时间
|
234
|
* @return exercise_time:演习时间
|
251
|
* @return address:演习地点
|
235
|
* @return address:演习地点
|
252
|
* @return images:完善图片@
|
236
|
* @return images:完善图片@
|
|
@@ -268,7 +252,7 @@ class ExerciseController extends RestBaseController |
|
@@ -268,7 +252,7 @@ class ExerciseController extends RestBaseController |
268
|
if($user['identity'] != config('site.a_staff') && $user['identity'] != config('site.b_staff')){
|
252
|
if($user['identity'] != config('site.a_staff') && $user['identity'] != config('site.b_staff')){
|
269
|
$this->error('无权操作');
|
253
|
$this->error('无权操作');
|
270
|
}
|
254
|
}
|
271
|
- $field = 'id,exercise_time,address,images,number,project_id';
|
255
|
+ $field = 'id,exercise_time,title,address,images,number,project_id';
|
272
|
$res = $common->getExerciseById(['id'=>$id,'status'=>2],$field);
|
256
|
$res = $common->getExerciseById(['id'=>$id,'status'=>2],$field);
|
273
|
if($res){
|
257
|
if($res){
|
274
|
//查询培训演习项目
|
258
|
//查询培训演习项目
|
|
@@ -313,11 +297,15 @@ class ExerciseController extends RestBaseController |
|
@@ -313,11 +297,15 @@ class ExerciseController extends RestBaseController |
313
|
$this->error('无权操作');
|
297
|
$this->error('无权操作');
|
314
|
}
|
298
|
}
|
315
|
$exerciseModel = new ExerciseModel();
|
299
|
$exerciseModel = new ExerciseModel();
|
316
|
-
|
|
|
317
|
$images = $common->relationUrl($data['images']);
|
300
|
$images = $common->relationUrl($data['images']);
|
318
|
-
|
|
|
319
|
- $res = $exerciseModel->where(['id'=>$data['id'],'status'=>2])->update(['images'=>$images]);
|
301
|
+ $res = $exerciseModel->where(['id'=>$data['id'],'status'=>1])->update(['images'=>$images]);
|
320
|
if($res){
|
302
|
if($res){
|
|
|
303
|
+ //记录参与人员id
|
|
|
304
|
+ $project = $common->getLaunchUid('exercise',$data['id']);
|
|
|
305
|
+ $join_uid['project_id'] = $project['project_id'];
|
|
|
306
|
+ $join_uid['create_time'] = time();
|
|
|
307
|
+ $common->createInsUid($join_uid,6);
|
|
|
308
|
+
|
321
|
$this->success('成功');
|
309
|
$this->success('成功');
|
322
|
}else{
|
310
|
}else{
|
323
|
$this->error('失败');
|
311
|
$this->error('失败');
|
|
@@ -328,17 +316,18 @@ class ExerciseController extends RestBaseController |
|
@@ -328,17 +316,18 @@ class ExerciseController extends RestBaseController |
328
|
}
|
316
|
}
|
329
|
|
317
|
|
330
|
/**
|
318
|
/**
|
331
|
- * @title 甲乙方员工完成演习单
|
319
|
+ * @title 乙方员工完成演习单
|
332
|
* @description 接口说明
|
320
|
* @description 接口说明
|
333
|
* @author 开发者
|
321
|
* @author 开发者
|
334
|
- * @url /api/home/exercise/finishExercise
|
322
|
+ * @url /api/home/exercise/finishExerciseB
|
335
|
* @method POST
|
323
|
* @method POST
|
336
|
*
|
324
|
*
|
337
|
* @header name:token require:1 default: desc:header
|
325
|
* @header name:token require:1 default: desc:header
|
338
|
* @param name:id type:inter require:1 default: other desc:列表id
|
326
|
* @param name:id type:inter require:1 default: other desc:列表id
|
339
|
* @param name:confirm_images type:file require:1 default: other desc:验收照片(二维数组形式)
|
327
|
* @param name:confirm_images type:file require:1 default: other desc:验收照片(二维数组形式)
|
|
|
328
|
+ * @param name:u_ids type:string require:1 default: other desc:甲方被演习人员字符串逗号拼接("2,4,5,8")
|
340
|
*/
|
329
|
*/
|
341
|
- public function finishExercise(){
|
330
|
+ public function finishExerciseB(){
|
342
|
if($this->request->isPost()){
|
331
|
if($this->request->isPost()){
|
343
|
$data = $this->request->post();
|
332
|
$data = $this->request->post();
|
344
|
$rule = config('site.check_exercise');
|
333
|
$rule = config('site.check_exercise');
|
|
@@ -349,34 +338,97 @@ class ExerciseController extends RestBaseController |
|
@@ -349,34 +338,97 @@ class ExerciseController extends RestBaseController |
349
|
|
338
|
|
350
|
$common = new CommonController();
|
339
|
$common = new CommonController();
|
351
|
$user = $common->getIdentity();
|
340
|
$user = $common->getIdentity();
|
352
|
- //如果不是甲乙方员工,则无权操作
|
|
|
353
|
- if($user['identity'] != config('site.a_staff') && $user['identity'] != config('site.b_staff')){
|
341
|
+ //如果不是乙方员工,则无权操作
|
|
|
342
|
+ if($user['identity'] != config('site.b_staff')){
|
354
|
$this->error('无权操作');
|
343
|
$this->error('无权操作');
|
355
|
}
|
344
|
}
|
356
|
$exerciseModel = new ExerciseModel();
|
345
|
$exerciseModel = new ExerciseModel();
|
357
|
-
|
|
|
358
|
$confirm_images = $common->relationUrl($data['confirm_images']);
|
346
|
$confirm_images = $common->relationUrl($data['confirm_images']);
|
359
|
$arr = [
|
347
|
$arr = [
|
360
|
- 'confirm_uid'=>$this->userId,
|
|
|
361
|
- 'finish_time'=>time(),
|
|
|
362
|
- 'status'=>3,
|
|
|
363
|
- 'confirm_images'=>$confirm_images
|
348
|
+ 'confirm_images'=>$confirm_images,
|
|
|
349
|
+ 'confirm_uid'=>$this->userId
|
364
|
];
|
350
|
];
|
365
|
- $res = $exerciseModel->where(['id'=>$data['id'],'status'=>2])->update($arr);
|
351
|
+ $res = $exerciseModel->where(['id'=>$data['id'],'status'=>1])->update($arr);
|
366
|
if($res){
|
352
|
if($res){
|
367
|
- //推送
|
|
|
368
|
- //甲方确认完成,提醒甲乙方领导
|
|
|
369
|
- $project = $common->getProjectId('exercise',['id'=>$data['id']],'id,project_id');
|
|
|
370
|
- $user_ids = $common->getLeadersId($project['project_id']);
|
|
|
371
|
- $content = config('site.exercise_content_finish');
|
353
|
+ //记录参与人员id
|
|
|
354
|
+ $project = $common->getLaunchUid('exercise',$data['id']);
|
|
|
355
|
+ $join_uid['project_id'] = $project['project_id'];
|
|
|
356
|
+ $join_uid['create_time'] = time();
|
|
|
357
|
+ $common->createInsUid($join_uid,6);
|
372
|
|
358
|
|
373
|
- $registration_id = $common->getPushUsers($user_ids);
|
|
|
374
|
- if($registration_id){
|
|
|
375
|
- $common = new CommonController();
|
|
|
376
|
- $title = config('site.title');
|
|
|
377
|
- $common->pushMessage($registration_id,$content,$title);
|
359
|
+ //指派甲方人员
|
|
|
360
|
+ $u_ids = explode(',',$data['u_ids']);
|
|
|
361
|
+ $user['c_id'] = $data['id'];
|
|
|
362
|
+ $user['create_time'] = time();
|
|
|
363
|
+ $user['type'] = 1;
|
|
|
364
|
+ $confirmModel = new ConfirmImageModel();
|
|
|
365
|
+ foreach ($u_ids as $value) {
|
|
|
366
|
+ $user['uid'] = $value;
|
|
|
367
|
+ $confirmModel->create($user);
|
378
|
}
|
368
|
}
|
379
|
|
369
|
|
|
|
370
|
+ $this->success('成功');
|
|
|
371
|
+ }else{
|
|
|
372
|
+ $this->error('失败');
|
|
|
373
|
+ }
|
|
|
374
|
+ }else{
|
|
|
375
|
+ $this->error('请求方式错误!');
|
|
|
376
|
+ }
|
|
|
377
|
+ }
|
|
|
378
|
+
|
|
|
379
|
+ /**
|
|
|
380
|
+ * @title 甲方员工完成演习单
|
|
|
381
|
+ * @description 接口说明
|
|
|
382
|
+ * @author 开发者
|
|
|
383
|
+ * @url /api/home/exercise/finishTrainA
|
|
|
384
|
+ * @method POST
|
|
|
385
|
+ *
|
|
|
386
|
+ * @header name:token require:1 default: desc:header
|
|
|
387
|
+ * @param name:id type:inter require:1 default: other desc:列表id
|
|
|
388
|
+ * @param name:confirm_images type:file require:1 default: other desc:验收照片(二维数组形式)
|
|
|
389
|
+ */
|
|
|
390
|
+ public function finishTrainA(){
|
|
|
391
|
+ if($this->request->isPost()){
|
|
|
392
|
+ $data = $this->request->post();
|
|
|
393
|
+ $rule = config('site.check_train_a');
|
|
|
394
|
+ $validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
395
|
+ if (!$validate->check($data)) {
|
|
|
396
|
+ $this->error($validate->getError());
|
|
|
397
|
+ }
|
|
|
398
|
+
|
|
|
399
|
+ $common = new CommonController();
|
|
|
400
|
+ $user = $common->getIdentity();
|
|
|
401
|
+ //如果不是甲方员工,则无权操作
|
|
|
402
|
+ if($user['identity'] != config('site.a_staff')){
|
|
|
403
|
+ $this->error('无权操作');
|
|
|
404
|
+ }
|
|
|
405
|
+ $confirm_images = $common->relationUrl($data['confirm_images']);
|
|
|
406
|
+ $arr = [
|
|
|
407
|
+ 'confirm_images'=>$confirm_images,
|
|
|
408
|
+ 'is_image' => 0,
|
|
|
409
|
+ ];
|
|
|
410
|
+ $confirmModel = new ConfirmImageModel();
|
|
|
411
|
+ $res = $confirmModel->where(['c_id'=>$data['id'],'type'=>1,'uid'=>$this->userId])->update($arr);
|
|
|
412
|
+ if($res){
|
|
|
413
|
+ //记录参与人员id
|
|
|
414
|
+ $project = $common->getLaunchUid('train',$data['id']);
|
|
|
415
|
+ $join_uid['project_id'] = $project['project_id'];
|
|
|
416
|
+ $join_uid['create_time'] = time();
|
|
|
417
|
+ $common->createInsUid($join_uid,6);
|
|
|
418
|
+
|
|
|
419
|
+ //查询培训单 甲方员工是否全部完成
|
|
|
420
|
+ //已完成
|
|
|
421
|
+ $finish_count = $common->getFinishCount(['type'=>1,'c_id'=>$data['id'],'is_image'=>0]);
|
|
|
422
|
+ //所有
|
|
|
423
|
+ $count = $common->getFinishCount(['type'=>1,'c_id'=>$data['id']]);
|
|
|
424
|
+ if($finish_count == $count){
|
|
|
425
|
+ //全部甲方员已完成,更新状态已完成
|
|
|
426
|
+ $exerciseModel = new ExerciseModel();
|
|
|
427
|
+ $exerciseModel->where(['id'=>$data['id'],'status'=>1])->update(['status'=>2,'finish_time'=>time()]);
|
|
|
428
|
+
|
|
|
429
|
+ //推送系统指定人员
|
|
|
430
|
+
|
|
|
431
|
+ }
|
380
|
|
432
|
|
381
|
$this->success('成功');
|
433
|
$this->success('成功');
|
382
|
}else{
|
434
|
}else{
|