reward_summary.go
4.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
package domain
import (
"time"
)
// RewardSummary 功过奖惩明细
type RewardSummary struct {
Id int `json:"id"`
CompanyId int `json:"companyId"`
OrgId int `json:"orgId"`
RecordDate time.Time `json:"recordDate"` //日期
RecordDateStr string `json:"recordDateStr"` //
WorkStation WorkStation `json:"workStation"` //工作位置
Worker User `json:"user"` //员工
UpToStandard float64 `json:"upToStandard"` //合格率
UpToStandardResult int `json:"upToStandardResult"` //合格率 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
Yield float64 `json:"yield"` //产能
YieldResult int `json:"yieldResult"` //产能 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
AccidentNum1 int `json:"accidentNum1"` //质量事故 次数
AccidentAmount1 float64 `json:"accidentAmount1"` //质量事故 损失金额
AccidentResult1 int `json:"accidentResult1"` //质量事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
AccidentNum2 int `json:"accidentNum2"` //安全事故 次数
AccidentAmount2 float64 `json:"accidentAmount2"` //安全事故 损失金额
AccidentResult2 int `json:"accidentResult2"` //安全事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
AccidentNum3 int `json:"accidentNum3"` //异物金属事故 次数
AccidentResult3 int `json:"accidentResult3"` //异物金属事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
AccidentNum4 int `json:"accidentNum4"` //异物非金属事故 次数
AccidentResult4 int `json:"accidentResult4"` //异物非金属事故 功过评定结果 1`功` -1 `过` 0 `不奖不惩`
SummaryResult float64 `json:"summaryResult"` //奖惩金额计算结果(元)
CreatedAt time.Time `json:"createdAt"` //
UpdatedAt time.Time `json:"UpdatedAt"` //
}
type RewardSummaryRepository interface {
Save(param *RewardSummary) (*RewardSummary, error)
FindOne(queryOptions map[string]interface{}) (*RewardSummary, error)
Find(queryOptions map[string]interface{}) (int64, []*RewardSummary, error)
}
// SummaryAccident 汇总事故数据
func (c *RewardSummary) SummaryAccident(trouble *ProductTrouble, rewardStandard *RewardStandard) {
switch trouble.Types {
case TroubleType1:
c.AccidentNum2 = +1
c.AccidentAmount2 = +trouble.AmountLoss
if rewardStandard == nil {
c.AccidentResult2 = 0
} else {
r := rewardStandard.VerdictTargetType3(c.AccidentNum2, c.AccidentAmount2)
c.AccidentResult2 = r
}
case TroubleType2:
c.AccidentNum1 = +1
c.AccidentAmount1 = +trouble.AmountLoss
if rewardStandard == nil {
c.AccidentResult1 = 0
} else {
r := rewardStandard.VerdictTargetType4(c.AccidentNum1, c.AccidentAmount1)
c.AccidentResult2 = r
}
case TroubleType3:
c.AccidentNum3 = +1
if rewardStandard == nil {
c.AccidentResult3 = 0
} else {
r := rewardStandard.VerdictTargetType5(c.AccidentNum3, 0)
c.AccidentResult2 = r
}
case TroubleType4:
c.AccidentNum4 = +1
if rewardStandard == nil {
c.AccidentResult4 = 0
} else {
r := rewardStandard.VerdictTargetType5(0, c.AccidentNum4)
c.AccidentResult2 = r
}
}
}
func (c *RewardSummary) ApplySummaryResult(rule *RewardRule) {
rewardNum := 0
faultNum := 0
if c.AccidentResult1 < 0 {
faultNum = +1
} else if c.AccidentResult1 > 0 {
rewardNum = +1
}
if c.AccidentResult2 < 0 {
faultNum = +1
} else if c.AccidentResult2 > 0 {
rewardNum = +1
}
if c.AccidentResult3 < 0 {
faultNum = +1
} else if c.AccidentResult3 > 0 {
rewardNum = +1
}
if c.AccidentResult4 < 0 {
faultNum = +1
} else if c.AccidentResult4 > 0 {
rewardNum = +1
}
if c.YieldResult < 0 {
faultNum = +1
} else if c.YieldResult > 0 {
rewardNum = +1
}
if c.UpToStandardResult < 0 {
faultNum = +1
} else if c.UpToStandardResult > 0 {
rewardNum = +1
}
c.SummaryResult = rule.SumRewardAmount(rewardNum, faultNum)
}