|
@@ -53,6 +53,49 @@ func (d *RewardSumaryDao) SeachRewardSummaryDay(companyId int, orgId int, record |
|
@@ -53,6 +53,49 @@ func (d *RewardSumaryDao) SeachRewardSummaryDay(companyId int, orgId int, record |
53
|
tx := d.transactionContext.PgTx
|
53
|
tx := d.transactionContext.PgTx
|
54
|
var result []RewardSummaryDay
|
54
|
var result []RewardSummaryDay
|
55
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
55
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
|
|
56
|
+
|
|
|
57
|
+ for i := range result {
|
|
|
58
|
+ switch result[i].AccidentResult1 {
|
|
|
59
|
+ case "1":
|
|
|
60
|
+ result[i].AccidentResult1 = "功"
|
|
|
61
|
+ case "0":
|
|
|
62
|
+ result[i].AccidentResult1 = "不奖不惩"
|
|
|
63
|
+ case "-1":
|
|
|
64
|
+ result[i].AccidentResult1 = "过"
|
|
|
65
|
+ }
|
|
|
66
|
+ switch result[i].AccidentResult2 {
|
|
|
67
|
+ case "1":
|
|
|
68
|
+ result[i].AccidentResult2 = "功"
|
|
|
69
|
+ case "0":
|
|
|
70
|
+ result[i].AccidentResult2 = "不奖不惩"
|
|
|
71
|
+ case "-1":
|
|
|
72
|
+ result[i].AccidentResult2 = "过"
|
|
|
73
|
+ }
|
|
|
74
|
+ switch result[i].AccidentResult3 {
|
|
|
75
|
+ case "1":
|
|
|
76
|
+ result[i].AccidentResult3 = "功"
|
|
|
77
|
+ case "0":
|
|
|
78
|
+ result[i].AccidentResult3 = "不奖不惩"
|
|
|
79
|
+ case "-1":
|
|
|
80
|
+ result[i].AccidentResult3 = "过"
|
|
|
81
|
+ }
|
|
|
82
|
+ switch result[i].UpToStandardResult {
|
|
|
83
|
+ case "1":
|
|
|
84
|
+ result[i].UpToStandardResult = "功"
|
|
|
85
|
+ case "0":
|
|
|
86
|
+ result[i].UpToStandardResult = "不奖不惩"
|
|
|
87
|
+ case "-1":
|
|
|
88
|
+ result[i].UpToStandardResult = "过"
|
|
|
89
|
+ }
|
|
|
90
|
+ switch result[i].YieldResult {
|
|
|
91
|
+ case "1":
|
|
|
92
|
+ result[i].YieldResult = "功"
|
|
|
93
|
+ case "0":
|
|
|
94
|
+ result[i].YieldResult = "不奖不惩"
|
|
|
95
|
+ case "-1":
|
|
|
96
|
+ result[i].YieldResult = "过"
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
56
|
return result, err
|
99
|
return result, err
|
57
|
}
|
100
|
}
|
58
|
|
101
|
|
|
@@ -68,20 +111,61 @@ type RewardSummaryYield struct { |
|
@@ -68,20 +111,61 @@ type RewardSummaryYield struct { |
68
|
|
111
|
|
69
|
// 功过看板-产效
|
112
|
// 功过看板-产效
|
70
|
func (d *RewardSumaryDao) SeachRewardSummaryYield(companyId int, orgId int, recordDate string) ([]RewardSummaryYield, error) {
|
113
|
func (d *RewardSumaryDao) SeachRewardSummaryYield(companyId int, orgId int, recordDate string) ([]RewardSummaryYield, error) {
|
71
|
- sqlStr := `SELECT
|
114
|
+ // sqlStr := `SELECT
|
|
|
115
|
+ // record_date_str,
|
|
|
116
|
+ // work_station->>'sectionName' as section_name,
|
|
|
117
|
+ // worker->>'userName' as worker_name,
|
|
|
118
|
+ // yield_result,
|
|
|
119
|
+ // yield,
|
|
|
120
|
+ // '24' as yield_max
|
|
|
121
|
+ // FROM manufacture."reward_summary"
|
|
|
122
|
+ // WHERE company_id=?
|
|
|
123
|
+ // and org_id=?
|
|
|
124
|
+ // and record_date_str=?`
|
|
|
125
|
+
|
|
|
126
|
+ sqlStr := `with
|
|
|
127
|
+ t1 as( SELECT
|
|
|
128
|
+ max(yield) as yield_max,
|
|
|
129
|
+ work_station->>'sectionId' AS section_id,
|
|
|
130
|
+ worker->>'userId' as worker_id
|
|
|
131
|
+ FROM manufacture."reward_summary"
|
|
|
132
|
+ WHERE company_id=? and org_id=?
|
|
|
133
|
+ GROUP BY section_id,worker_id
|
|
|
134
|
+ ),
|
|
|
135
|
+ t2 as (SELECT
|
72
|
record_date_str,
|
136
|
record_date_str,
|
|
|
137
|
+ work_station->>'sectionId' AS section_id,
|
|
|
138
|
+ worker->>'userId' as worker_id,
|
73
|
work_station->>'sectionName' as section_name,
|
139
|
work_station->>'sectionName' as section_name,
|
74
|
worker->>'userName' as worker_name,
|
140
|
worker->>'userName' as worker_name,
|
75
|
yield_result,
|
141
|
yield_result,
|
76
|
- yield,
|
|
|
77
|
- '24' as yield_max
|
142
|
+ yield
|
78
|
FROM manufacture."reward_summary"
|
143
|
FROM manufacture."reward_summary"
|
79
|
- WHERE company_id=?
|
|
|
80
|
- and org_id=?
|
|
|
81
|
- and record_date_str=?`
|
144
|
+ WHERE company_id=? and org_id=?
|
|
|
145
|
+ and record_date_str=?
|
|
|
146
|
+ )
|
|
|
147
|
+ SELECT t2.record_date_str,t2.section_name,t2.worker_name,
|
|
|
148
|
+ t2.yield_result,t2.yield,t1.yield_max
|
|
|
149
|
+ FROM t2
|
|
|
150
|
+ JOIN t1 on t2.section_id=t1.section_id AND t2.worker_id=t2.worker_id`
|
|
|
151
|
+
|
82
|
tx := d.transactionContext.PgTx
|
152
|
tx := d.transactionContext.PgTx
|
83
|
var result []RewardSummaryYield
|
153
|
var result []RewardSummaryYield
|
84
|
- _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
154
|
+ params := []interface{}{
|
|
|
155
|
+ companyId, orgId,
|
|
|
156
|
+ companyId, orgId, recordDate,
|
|
|
157
|
+ }
|
|
|
158
|
+ _, err := tx.Query(&result, sqlStr, params...)
|
|
|
159
|
+ for i := range result {
|
|
|
160
|
+ switch result[i].YieldResult {
|
|
|
161
|
+ case "1":
|
|
|
162
|
+ result[i].YieldResult = "功"
|
|
|
163
|
+ case "0":
|
|
|
164
|
+ result[i].YieldResult = "不奖不惩"
|
|
|
165
|
+ case "-1":
|
|
|
166
|
+ result[i].YieldResult = "过"
|
|
|
167
|
+ }
|
|
|
168
|
+ }
|
85
|
return result, err
|
169
|
return result, err
|
86
|
|
170
|
|
87
|
}
|
171
|
}
|
|
@@ -98,20 +182,59 @@ type RewardSummaryUpToStandard struct { |
|
@@ -98,20 +182,59 @@ type RewardSummaryUpToStandard struct { |
98
|
|
182
|
|
99
|
// 功过看板-合格率
|
183
|
// 功过看板-合格率
|
100
|
func (d *RewardSumaryDao) SeachRewardUpToStandard(companyId int, orgId int, recordDate string) ([]RewardSummaryUpToStandard, error) {
|
184
|
func (d *RewardSumaryDao) SeachRewardUpToStandard(companyId int, orgId int, recordDate string) ([]RewardSummaryUpToStandard, error) {
|
101
|
- sqlStr := `SELECT
|
185
|
+ // sqlStr := `SELECT
|
|
|
186
|
+ // record_date_str,
|
|
|
187
|
+ // work_station->>'sectionName' as section_name,
|
|
|
188
|
+ // worker->>'userName' as worker_name,
|
|
|
189
|
+ // up_to_standard_result,
|
|
|
190
|
+ // up_to_standard,
|
|
|
191
|
+ // '90' as up_to_standard_max
|
|
|
192
|
+ // FROM manufacture."reward_summary"
|
|
|
193
|
+ // WHERE company_id=23
|
|
|
194
|
+ // and org_id=487
|
|
|
195
|
+ // and record_date_str='2022-10-29'`
|
|
|
196
|
+ sqlStr := `with
|
|
|
197
|
+ t1 as( SELECT
|
|
|
198
|
+ max(up_to_standard) as up_to_standard_max,
|
|
|
199
|
+ work_station->>'sectionId' AS section_id,
|
|
|
200
|
+ worker->>'userId' as worker_id
|
|
|
201
|
+ FROM manufacture."reward_summary"
|
|
|
202
|
+ WHERE company_id=? and org_id=?
|
|
|
203
|
+ GROUP BY section_id,worker_id
|
|
|
204
|
+ ),
|
|
|
205
|
+ t2 as (SELECT
|
102
|
record_date_str,
|
206
|
record_date_str,
|
|
|
207
|
+ work_station->>'sectionId' AS section_id,
|
|
|
208
|
+ worker->>'userId' as worker_id,
|
103
|
work_station->>'sectionName' as section_name,
|
209
|
work_station->>'sectionName' as section_name,
|
104
|
worker->>'userName' as worker_name,
|
210
|
worker->>'userName' as worker_name,
|
105
|
up_to_standard_result,
|
211
|
up_to_standard_result,
|
106
|
- up_to_standard,
|
|
|
107
|
- '90' as up_to_standard_max
|
212
|
+ up_to_standard
|
108
|
FROM manufacture."reward_summary"
|
213
|
FROM manufacture."reward_summary"
|
109
|
- WHERE company_id=23
|
|
|
110
|
- and org_id=487
|
|
|
111
|
- and record_date_str='2022-10-29'`
|
214
|
+ WHERE company_id=? and org_id=?
|
|
|
215
|
+ and record_date_str=?
|
|
|
216
|
+ )
|
|
|
217
|
+ SELECT t2.record_date_str,t2.section_name,t2.worker_name,
|
|
|
218
|
+ t2.up_to_standard_result,t2.up_to_standard,t1.up_to_standard_max
|
|
|
219
|
+ FROM t2
|
|
|
220
|
+ JOIN t1 on t2.section_id=t1.section_id AND t2.worker_id=t2.worker_id`
|
112
|
tx := d.transactionContext.PgTx
|
221
|
tx := d.transactionContext.PgTx
|
113
|
var result []RewardSummaryUpToStandard
|
222
|
var result []RewardSummaryUpToStandard
|
114
|
- _, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
223
|
+ params := []interface{}{
|
|
|
224
|
+ companyId, orgId,
|
|
|
225
|
+ companyId, orgId, recordDate,
|
|
|
226
|
+ }
|
|
|
227
|
+ _, err := tx.Query(&result, sqlStr, params...)
|
|
|
228
|
+ for i := range result {
|
|
|
229
|
+ switch result[i].UpToStandardResult {
|
|
|
230
|
+ case "1":
|
|
|
231
|
+ result[i].UpToStandardResult = "功"
|
|
|
232
|
+ case "0":
|
|
|
233
|
+ result[i].UpToStandardResult = "不奖不惩"
|
|
|
234
|
+ case "-1":
|
|
|
235
|
+ result[i].UpToStandardResult = "过"
|
|
|
236
|
+ }
|
|
|
237
|
+ }
|
115
|
return result, err
|
238
|
return result, err
|
116
|
}
|
239
|
}
|
117
|
|
240
|
|
|
@@ -121,11 +244,14 @@ type RewardAccident struct { |
|
@@ -121,11 +244,14 @@ type RewardAccident struct { |
121
|
RecordDateStr string `json:"record_date_str"`
|
244
|
RecordDateStr string `json:"record_date_str"`
|
122
|
SectionName string `json:"sectionName"` //工段名称
|
245
|
SectionName string `json:"sectionName"` //工段名称
|
123
|
WorkerName string `json:"workerName"` //员工名称
|
246
|
WorkerName string `json:"workerName"` //员工名称
|
124
|
- SummaryResult string `json:"summaryResult"` //奖惩结果
|
|
|
125
|
- YieldResult string `json:"yieldResult"` //产效功过结果
|
|
|
126
|
- UpToStandardResult string `json:"upToStandardResult"` //合格率功过结果
|
247
|
+ AccidentAmount1 string `json:"accidentAmount1"` //质量事故损失金额
|
|
|
248
|
+ AccidentNum1 string `json:"accidentNum1"` //质量事故次数
|
127
|
AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果
|
249
|
AccidentResult1 string `json:"accidentResult1"` //质量事故功过结果
|
|
|
250
|
+ AccidentAmount2 string `json:"accidentAmount2"` //安全事故 损失金额
|
128
|
AccidentResult2 string `json:"accidentResul2"` //安全事故功过结果
|
251
|
AccidentResult2 string `json:"accidentResul2"` //安全事故功过结果
|
|
|
252
|
+ AccidentNum2 string `json:"accidentNum2"` //安全事故 次数
|
|
|
253
|
+ AccidentNum3 string `json:"accidentNum3"` //金属异物 次数
|
|
|
254
|
+ AccidentNum4 string `json:"accidentNum4"` //非属异物事故次数
|
129
|
AccidentResult3 string `json:"accidentResul3"` //异物 功过结果
|
255
|
AccidentResult3 string `json:"accidentResul3"` //异物 功过结果
|
130
|
}
|
256
|
}
|
131
|
|
257
|
|
|
@@ -135,9 +261,9 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa |
|
@@ -135,9 +261,9 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa |
135
|
"id",record_date_str,
|
261
|
"id",record_date_str,
|
136
|
work_station->>'sectionName' as section_name,
|
262
|
work_station->>'sectionName' as section_name,
|
137
|
worker->>'userName' as worker_name,
|
263
|
worker->>'userName' as worker_name,
|
138
|
- up_to_standard_result,
|
|
|
139
|
- up_to_standard,
|
|
|
140
|
- '90' as up_to_standard_max
|
264
|
+ accident_num1,accident_amount1,accident_result1,
|
|
|
265
|
+ accident_num2,accident_amount2,accident_result2,
|
|
|
266
|
+ accident_num3,accident_num4,accident_result3
|
141
|
FROM manufacture."reward_summary"
|
267
|
FROM manufacture."reward_summary"
|
142
|
WHERE company_id=?
|
268
|
WHERE company_id=?
|
143
|
and org_id=?
|
269
|
and org_id=?
|
|
@@ -145,10 +271,37 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa |
|
@@ -145,10 +271,37 @@ func (d *RewardSumaryDao) SeachRewardAccident(companyId int, orgId int, recordDa |
145
|
tx := d.transactionContext.PgTx
|
271
|
tx := d.transactionContext.PgTx
|
146
|
var result []RewardAccident
|
272
|
var result []RewardAccident
|
147
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
273
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordDate)
|
|
|
274
|
+
|
|
|
275
|
+ for i := range result {
|
|
|
276
|
+ switch result[i].AccidentResult1 {
|
|
|
277
|
+ case "1":
|
|
|
278
|
+ result[i].AccidentResult1 = "功"
|
|
|
279
|
+ case "0":
|
|
|
280
|
+ result[i].AccidentResult1 = "不奖不惩"
|
|
|
281
|
+ case "-1":
|
|
|
282
|
+ result[i].AccidentResult1 = "过"
|
|
|
283
|
+ }
|
|
|
284
|
+ switch result[i].AccidentResult2 {
|
|
|
285
|
+ case "1":
|
|
|
286
|
+ result[i].AccidentResult2 = "功"
|
|
|
287
|
+ case "0":
|
|
|
288
|
+ result[i].AccidentResult2 = "不奖不惩"
|
|
|
289
|
+ case "-1":
|
|
|
290
|
+ result[i].AccidentResult2 = "过"
|
|
|
291
|
+ }
|
|
|
292
|
+ switch result[i].AccidentResult3 {
|
|
|
293
|
+ case "1":
|
|
|
294
|
+ result[i].AccidentResult3 = "功"
|
|
|
295
|
+ case "0":
|
|
|
296
|
+ result[i].AccidentResult3 = "不奖不惩"
|
|
|
297
|
+ case "-1":
|
|
|
298
|
+ result[i].AccidentResult3 = "过"
|
|
|
299
|
+ }
|
|
|
300
|
+ }
|
148
|
return result, err
|
301
|
return result, err
|
149
|
}
|
302
|
}
|
150
|
|
303
|
|
151
|
-// 功过看板-异常
|
304
|
+// 功过看板-月榜
|
152
|
type RewardSummaryMonth struct {
|
305
|
type RewardSummaryMonth struct {
|
153
|
SectionId string `json:"sectionId"` //工段名称
|
306
|
SectionId string `json:"sectionId"` //工段名称
|
154
|
SectionName string `json:"sectionName"` //工段名称
|
307
|
SectionName string `json:"sectionName"` //工段名称
|
|
@@ -170,32 +323,35 @@ type RewardSummaryMonth struct { |
|
@@ -170,32 +323,35 @@ type RewardSummaryMonth struct { |
170
|
|
323
|
|
171
|
// 功过看板-月榜
|
324
|
// 功过看板-月榜
|
172
|
func (d *RewardSumaryDao) SeachRewardSummaryMonth(companyId int, orgId int, recordMonth string) ([]RewardSummaryMonth, error) {
|
325
|
func (d *RewardSumaryDao) SeachRewardSummaryMonth(companyId int, orgId int, recordMonth string) ([]RewardSummaryMonth, error) {
|
173
|
- sqlStr := `SELECT
|
|
|
174
|
-work_station->>'sectionId' AS section_id,
|
|
|
175
|
-work_station->>'sectionName' as section_name,
|
|
|
176
|
-worker->>'userId' as worker_id,
|
|
|
177
|
-worker->>'userName' as worker_name,
|
|
|
178
|
-count(accident_num1) as accident_num1,
|
|
|
179
|
-count(accident_num2) as accident_num2,
|
|
|
180
|
-count(accident_num3) as accident_num3,
|
|
|
181
|
-count(accident_num4) as accident_num4,
|
|
|
182
|
-count(accident_amount1) as accident_amount1,
|
|
|
183
|
-count(accident_amount2) as accident_amount2,
|
|
|
184
|
-'12' as yield_avg,
|
|
|
185
|
-'13' as yield_max,
|
|
|
186
|
-'-39' as amount_fine,
|
|
|
187
|
-'25' as amount_reward,
|
|
|
188
|
-'-14' as amount_final,
|
|
|
189
|
-'12' as up_to_standard,
|
326
|
+ sqlStr := `
|
|
|
327
|
+ SELECT
|
|
|
328
|
+ work_station->>'sectionId' AS section_id,
|
|
|
329
|
+ work_station->>'sectionName' as section_name,
|
|
|
330
|
+ worker->>'userId' as worker_id,
|
|
|
331
|
+ worker->>'userName' as worker_name,
|
|
|
332
|
+ sum(accident_num1) as accident_num1,
|
|
|
333
|
+ sum(accident_num2) as accident_num2,
|
|
|
334
|
+ sum(accident_num3) as accident_num3,
|
|
|
335
|
+ sum(accident_num4) as accident_num4,
|
|
|
336
|
+ sum(accident_amount1) as accident_amount1,
|
|
|
337
|
+ sum(accident_amount2) as accident_amount2,
|
|
|
338
|
+ CAST(sum(summary_result) as decimal(10,2)) as amount_final,
|
|
|
339
|
+ CAST(
|
|
|
340
|
+ sum(CASE WHEN summary_result<0 THEN summary_result ELSE 0 END) as decimal(10,2)
|
|
|
341
|
+ ) as amount_fine,
|
|
|
342
|
+ CAST(
|
|
|
343
|
+ sum(CASE WHEN summary_result>0 THEN summary_result ELSE 0 END) as decimal(10,2)
|
|
|
344
|
+ ) as amount_reward,
|
|
|
345
|
+ max(yield) as yield_max,
|
|
|
346
|
+ CAST(avg(yield) as decimal(10,2)) as yield_avg,
|
|
|
347
|
+ CAST(avg(up_to_standard) as decimal(10,2) ) as up_to_standard
|
190
|
FROM manufacture.reward_summary
|
348
|
FROM manufacture.reward_summary
|
191
|
WHERE company_id=?
|
349
|
WHERE company_id=?
|
192
|
and org_id=?
|
350
|
and org_id=?
|
193
|
and record_month_str=?
|
351
|
and record_month_str=?
|
194
|
-GROUP BY
|
|
|
195
|
-worker->>'userId' ,
|
|
|
196
|
-worker->>'userName' ,
|
|
|
197
|
-work_station->>'sectionId',
|
|
|
198
|
-work_station->>'sectionName' `
|
352
|
+ GROUP BY section_id,worker_id,worker_name,section_name
|
|
|
353
|
+ ;
|
|
|
354
|
+ `
|
199
|
tx := d.transactionContext.PgTx
|
355
|
tx := d.transactionContext.PgTx
|
200
|
var result []RewardSummaryMonth
|
356
|
var result []RewardSummaryMonth
|
201
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordMonth)
|
357
|
_, err := tx.Query(&result, sqlStr, companyId, orgId, recordMonth)
|