task.go
21.3 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
package domain
import (
"fmt"
"time"
)
const (
TASK_TYPE_ROB = iota + 1 //抢单任务
TASK_TYPE_BID //竞标任务
TASK_TYPE_DESIGNATE //指派任务
)
const (
REFERENCE_RESOURCE_TYPE_ISSUE = iota + 1 //问题引用类型
REFERENCE_RESOURCE_TYPE_CHANCE //机会引用类型
)
const (
TASK_STATUS_UNRELEASED = iota + 1 //待发布
TASK_STATUS_UNCLAIMED //待领取
TASK_STATUS_UNDERWAY //进行中
TASK_STATUS_UNACCEPTANCE //待验收
TASK_STATUS_COMPLETED //已完成
TASK_STATUS_CLOSED //关闭
TASK_STATUS_UNCONFIRMED //待确认
)
// 任务
type Task struct {
// 任务ID
TaskId int64 `json:"taskId"`
// 公司ID
CompanyId int64 `json:"companyId"`
// 任务名称
TaskName string `json:"taskName"`
// 任务类型Type
TaskType int `json:"taskType"`
// 任务发起者
Sponsor *EmployeeInfo `json:"sponsor"`
// 任务状态
TaskStatus int `json:"taskStatus"`
// 引用资源
ReferenceResource *ReferenceResource `json:"referenceResource"`
// 项目归属
ProjectBelong int `json:"projectBelong"`
// 客户价值列表
CustomerValues []int `json:"customerValues"`
// 任务性质
TaskNature int `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard"`
// 任务描述
TaskDescription string `json:"taskDescription"`
// 任务图片URL列表
TaskPictureUrls []string `json:"taskPictureUrls"`
// 是否悬赏任务
IsRewardTake bool `json:"isRewardTake"`
// 抢单任务信息
RobInfo *RobInfo `json:"robInfo"`
// 竞标任务信息
BidInfo *BidInfo `json:"bidInfo"`
// 任务参与者列表
Participators []*EmployeeInfo `json:"participators"`
// 任务贡献占比
TaskPercentage []*TaskPercentageItem `json:"taskPercentage"`
// 解决报告
SolveReport string `json:"solveReport"`
// 解决图片URL列表
SolvePictureUrls []string `json:"solvePictureUrls"`
// 指派人员
AssignedPerson *EmployeeInfo `json:"assignedPerson"`
// 计划完成时间
PlannedCompletionTime time.Time `json:"plannedCompletionTime"`
// 实际完成时间
ActualCompletionTime time.Time `json:"actualCompletionTime"`
// 创建时间
CreateTime time.Time `json:"createTime"`
// 发布任务时间
ReleaseTime time.Time `json:"releaseTime"`
// 领取任务时间
ReceiveTime time.Time `json:"receiveTime"`
// 完成任务操作时间
CompleteTime time.Time `json:"completeTime"`
// 验收方验收时间
AcceptanceTime time.Time `json:"acceptanceTime"`
//当前状态
CurrentStatus TaskStatus `json:"-"`
}
type TaskStatus interface {
Update(task *Task, data map[string]interface{}) error
Release(task *Task) error
Rob(task *Task, receiver *EmployeeInfo) error
Bib(task *Task, bidder *EmployeeInfo) error
ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error
ApplyComplete(task *Task) error
Off(task *Task) error
Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error
ConfirmTask(task *Task, plannedCompletionTime time.Time) error
RejectReceiver(task *Task) error
}
type UnReleasedStatus struct{}
func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error {
if taskName, ok := data["taskName"]; ok {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if projectBelong, ok := data["projectBelong"]; ok {
task.ProjectBelong = projectBelong.(int)
}
if customerValues, ok := data["customerValues"]; ok {
task.CustomerValues = customerValues.([]int)
}
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(int)
}
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
if task.TaskType == TASK_TYPE_DESIGNATE {
if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
}
if assignedPerson, ok := data["assignedPerson"]; ok {
task.AssignedPerson = assignedPerson.(*EmployeeInfo)
if task.AssignedPerson.Uid == 0 {
task.AssignedPerson = nil
}
}
}
return nil
}
func (status *UnReleasedStatus) Release(task *Task) error {
task.ReleaseTime = time.Now()
if task.TaskType == TASK_TYPE_DESIGNATE {
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
} else {
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
}
return nil
}
func (status *UnReleasedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("待发布的任务不允许抢单")
}
func (status *UnReleasedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待发布的任务不允许竞标")
}
func (status *UnReleasedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许选择竞标任务的中标人")
}
func (status *UnReleasedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("待发布的任务不允许申请完成任务")
}
func (status *UnReleasedStatus) Off(task *Task) error {
return fmt.Errorf("待发布的任务不允许关闭")
}
func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许验收")
}
func (status *UnReleasedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许确认任务领取人")
}
func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待发布的任务不允许驳回任务领取人")
}
type UnClaimedStatus struct{}
func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待领取的任务不允许编辑")
}
func (status *UnClaimedStatus) Release(task *Task) error {
return fmt.Errorf("待领取的任务不允许重新发布")
}
func (status *UnClaimedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
if task.TaskType != TASK_TYPE_ROB {
return fmt.Errorf("类型不符合的任务不允许抢单")
}
currentTime := time.Now()
task.RobInfo = &RobInfo{
Receiver: receiver,
ReceiveTime: currentTime,
}
task.ReceiveTime = currentTime
task.TaskStatus = TASK_STATUS_UNCONFIRMED
task.CurrentStatus = &UnConfirmedStatus{}
return nil
}
func (status *UnClaimedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
if task.TaskType != TASK_TYPE_BID {
return fmt.Errorf("类型不符合的任务不允许竞标")
}
currentTime := time.Now()
if task.BidInfo == nil {
return fmt.Errorf("无效的竞标信息")
} else {
bidTime := currentTime
if bidTime.Before(task.BidInfo.BidStartTime) {
return fmt.Errorf("竞标还没开始")
}
if bidTime.After(task.BidInfo.BidEndTime) {
return fmt.Errorf("竞标已经结束")
}
task.BidInfo.BidderInfos = append(task.BidInfo.BidderInfos, &BidderInfo{
Bidder: bidder,
BidTime: bidTime,
})
return nil
}
}
func (status *UnClaimedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
if task.TaskType != TASK_TYPE_BID {
return fmt.Errorf("类型不符合的任务不允许选择竞中标人")
}
if task.BidInfo == nil {
return fmt.Errorf("无效的竞标信息")
} else {
winBidTime := time.Now()
task.BidInfo.SuccessfulBidder = successfulBidder
task.BidInfo.WinBidTime = winBidTime
task.ReceiveTime = winBidTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.PlannedCompletionTime = plannedCompletionTime
task.CurrentStatus = &UnderwayStatus{}
return nil
}
}
func (status *UnClaimedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("待领取的任务不允许申请完成任务")
}
func (status *UnClaimedStatus) Off(task *Task) error {
task.TaskStatus = TASK_STATUS_CLOSED
task.CurrentStatus = &ClosedStatus{}
return nil
}
func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待领取的任务不允许验收")
}
func (status *UnClaimedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待领取的任务不允许确认任务领取人")
}
func (status *UnClaimedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待领取的任务不允许驳回任务领取人")
}
type UnderwayStatus struct{}
func (status *UnderwayStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("进行中的任务不允许编辑")
}
func (status *UnderwayStatus) Release(task *Task) error {
return fmt.Errorf("进行中的任务不允许重新发布")
}
func (status *UnderwayStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("进行中的任务不允许抢单")
}
func (status *UnderwayStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("进行中的任务不允许竞标")
}
func (status *UnderwayStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许选择竞标任务的中标人")
}
func (status *UnderwayStatus) ApplyComplete(task *Task) error {
task.TaskStatus = TASK_STATUS_UNACCEPTANCE
task.CompleteTime = time.Now()
task.CurrentStatus = &UnAcceptanceStatus{}
return nil
}
func (status *UnderwayStatus) Off(task *Task) error {
task.TaskStatus = TASK_STATUS_CLOSED
task.CurrentStatus = &ClosedStatus{}
return nil
}
func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许验收")
}
func (status *UnderwayStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许确认任务领取人")
}
func (status *UnderwayStatus) RejectReceiver(task *Task) error {
if task.TaskType == TASK_TYPE_DESIGNATE {
return fmt.Errorf("类型不符合的任务不允许驳回领取人")
}
if task.TaskType == TASK_TYPE_ROB {
task.RobInfo.Receiver = nil
task.RobInfo.ReceiveTime = time.Time{}
}
if task.TaskType == TASK_TYPE_BID {
task.BidInfo.SuccessfulBidder = nil
task.BidInfo.WinBidTime = time.Time{}
}
task.ReceiveTime = time.Time{}
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
return nil
}
type UnAcceptanceStatus struct{}
func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待验收的任务不允许编辑")
}
func (status *UnAcceptanceStatus) Release(task *Task) error {
return fmt.Errorf("待验收的任务不允许重新发布")
}
func (status *UnAcceptanceStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("待验收的任务不允许抢单")
}
func (status *UnAcceptanceStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待验收的任务不允许竞标")
}
func (status *UnAcceptanceStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待验收的任务不允许选择竞标任务的中标人")
}
func (status *UnAcceptanceStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("待验收的任务不允许申请完成任务")
}
func (status *UnAcceptanceStatus) Off(task *Task) error {
task.TaskStatus = TASK_STATUS_CLOSED
task.CurrentStatus = &ClosedStatus{}
return nil
}
func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
task.Participators = participators
task.TaskPercentage = taskPercentage
task.SolveReport = solveReport
task.SolvePictureUrls = solvePictureUrls
if task.ReferenceResource != nil {
for _, referenceResourceItem := range task.ReferenceResource.ReferenceResourceItems {
for _, referenceResourceScoreItem := range referenceResourceScore {
if referenceResourceItem.ReferenceResourceId == referenceResourceScoreItem.ReferenceResourceId {
referenceResourceItem.IssueScore = referenceResourceScoreItem.IssueScore
referenceResourceItem.SolveScore = referenceResourceScoreItem.SolveScore
}
}
}
}
task.ActualCompletionTime = actualCompletionTime
task.TaskStatus = TASK_STATUS_COMPLETED
task.AcceptanceTime = time.Now()
task.CurrentStatus = &CompletedStatus{}
return nil
}
func (status *UnAcceptanceStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("待验收的任务不允许确认任务领取人")
}
func (status *UnAcceptanceStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("待验收的任务不允许驳回任务领取人")
}
type CompletedStatus struct{}
func (status *CompletedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("已完成的任务不允许编辑")
}
func (status *CompletedStatus) Release(task *Task) error {
return fmt.Errorf("已完成的任务不允许重新发布")
}
func (status *CompletedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("已完成的任务不允许抢单")
}
func (status *CompletedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("已完成的任务不允许竞标")
}
func (status *CompletedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许选择竞标任务的中标人")
}
func (status *CompletedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("已完成的任务不允许关闭")
}
func (status *CompletedStatus) Off(task *Task) error {
return fmt.Errorf("已完成的任务不允许申请完成任务")
}
func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许验收")
}
func (status *CompletedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许确认任务领取人")
}
func (status *CompletedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已完成的任务不允许驳回任务领取人")
}
type ClosedStatus struct{}
func (status *ClosedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("已关闭的任务不允许编辑")
}
func (status *ClosedStatus) Release(task *Task) error {
return fmt.Errorf("已关闭的任务不允许重新发布")
}
func (status *ClosedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("已关闭的任务不允许抢单")
}
func (status *ClosedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("已关闭的任务不允许竞标")
}
func (status *ClosedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许选择竞标任务的中标人")
}
func (status *ClosedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("已关闭的任务不允许申请完成任务")
}
func (status *ClosedStatus) Off(task *Task) error {
return fmt.Errorf("已关闭的任务不允许关闭")
}
func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许验收")
}
func (status *ClosedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许确认任务领取人")
}
func (status *ClosedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已关闭的任务不允许驳回任务领取人")
}
type UnConfirmedStatus struct{}
func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待确认的任务不允许编辑")
}
func (status *UnConfirmedStatus) Release(task *Task) error {
return fmt.Errorf("待确认的任务不允许重新发布")
}
func (status *UnConfirmedStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("待确认的任务不允许抢单")
}
func (status *UnConfirmedStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("待确认的任务不允许竞标")
}
func (status *UnConfirmedStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("待确认的任务不允许选择竞标任务的中标人")
}
func (status *UnConfirmedStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("待确认的任务不允许申请完成任务")
}
func (status *UnConfirmedStatus) Off(task *Task) error {
task.TaskStatus = TASK_STATUS_CLOSED
task.CurrentStatus = &ClosedStatus{}
return nil
}
func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待确认的任务不允许验收")
}
func (status *UnConfirmedStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
task.PlannedCompletionTime = plannedCompletionTime
task.TaskStatus = TASK_STATUS_UNDERWAY
task.CurrentStatus = &UnderwayStatus{}
return nil
}
func (status *UnConfirmedStatus) RejectReceiver(task *Task) error {
if task.TaskType != TASK_TYPE_ROB {
return fmt.Errorf("类型不符合的任务不允许在待确认状态下驳回领取人")
}
task.RobInfo.Receiver = nil
task.RobInfo.ReceiveTime = time.Time{}
task.ReceiveTime = time.Time{}
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
return nil
}
type TaskRepository interface {
Save(task *Task) (*Task, error)
Remove(task *Task) (*Task, error)
FindOne(queryOptions map[string]interface{}) (*Task, error)
Find(queryOptions map[string]interface{}) (int64, []*Task, error)
}
func (task *Task) Identify() interface{} {
if task.TaskId == 0 {
return nil
}
return task.TaskId
}
func (task *Task) Update(data map[string]interface{}) error {
return task.CurrentStatus.Update(task, data)
}
func (task *Task) Release() error {
return task.CurrentStatus.Release(task)
}
func (task *Task) Rob(receiver *EmployeeInfo) error {
return task.CurrentStatus.Rob(task, receiver)
}
func (task *Task) Bib(bidder *EmployeeInfo) error {
return task.CurrentStatus.Bib(task, bidder)
}
func (task *Task) ChooseSuccessfulBidder(successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return task.CurrentStatus.ChooseSuccessfulBidder(task, successfulBidder, plannedCompletionTime)
}
func (task *Task) ApplyComplete() error {
return task.CurrentStatus.ApplyComplete(task)
}
func (task *Task) Off() error {
return task.CurrentStatus.Off(task)
}
func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime)
}
func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error {
return task.CurrentStatus.ConfirmTask(task, plannedCompletionTime)
}
func (task *Task) RejectReceiver() error {
return task.CurrentStatus.RejectReceiver(task)
}