質問編集履歴
2
ソースコードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
$sql .= " where shift_pattern_id > 0 ";
|
34
34
|
|
35
|
-
$sql .= " AND (res.type <>
|
35
|
+
$sql .= " AND (res.type <> 1 OR res.type IS NULL) ";
|
36
36
|
|
37
37
|
$sql .= " AND mt_employee_id = ? ";
|
38
38
|
|
1
補足の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -83,3 +83,209 @@
|
|
83
83
|
必要な情報があれば、コメントにお願いします。
|
84
84
|
|
85
85
|
随時、追記します。
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
タイムゾーン "Asia/Tokyo"
|
90
|
+
|
91
|
+
DB PostgresSQL 9.5
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
何を参考にしたか
|
96
|
+
|
97
|
+
→参考というよりは必要な構文を調べながら新しく作りました。
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
テーブル定義
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
■obc_work_histories
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
create table public.obc_work_histories (
|
110
|
+
|
111
|
+
id integer default nextval('obc_work_histories_id_seq') PRIMARY KEY
|
112
|
+
|
113
|
+
, mt_employee_id integer not null
|
114
|
+
|
115
|
+
, work_day date not null
|
116
|
+
|
117
|
+
, shift_pattern_id integer not null
|
118
|
+
|
119
|
+
, mt_work_reason_id integer not null
|
120
|
+
|
121
|
+
, work_start_time timestamp not null
|
122
|
+
|
123
|
+
, work_end_time timestamp not null
|
124
|
+
|
125
|
+
, reces_time time not null
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
, normal_working_time time not null
|
130
|
+
|
131
|
+
, daytime_over_time time not null
|
132
|
+
|
133
|
+
, midnight_over_time time not null
|
134
|
+
|
135
|
+
, total_over_time time not null
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
, paid_recess_time time not null
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
, leave_desk_1_datetime time not null
|
144
|
+
|
145
|
+
, arrive_desk_1_datetime time not null
|
146
|
+
|
147
|
+
, leave_desk_2_datetime time not null
|
148
|
+
|
149
|
+
, arrive_desk_2_datetime time not null
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
, note varchar(20) not null
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
, created_user integer not null
|
158
|
+
|
159
|
+
, created_datetime timestamp not null
|
160
|
+
|
161
|
+
, modified_user integer not null
|
162
|
+
|
163
|
+
, modified_datetime timestamp not null
|
164
|
+
|
165
|
+
);
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
■view_obc_work_histories
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
WITH owh AS (
|
174
|
+
|
175
|
+
SELECT obc_work_histories.id,
|
176
|
+
|
177
|
+
obc_work_histories.mt_employee_id,
|
178
|
+
|
179
|
+
obc_work_histories.work_day,
|
180
|
+
|
181
|
+
obc_work_histories.shift_pattern_id,
|
182
|
+
|
183
|
+
obc_work_histories.mt_work_reason_id,
|
184
|
+
|
185
|
+
obc_work_histories.work_start_time,
|
186
|
+
|
187
|
+
obc_work_histories.work_end_time,
|
188
|
+
|
189
|
+
obc_work_histories.reces_time,
|
190
|
+
|
191
|
+
obc_work_histories.normal_working_time,
|
192
|
+
|
193
|
+
obc_work_histories.daytime_over_time,
|
194
|
+
|
195
|
+
obc_work_histories.midnight_over_time,
|
196
|
+
|
197
|
+
obc_work_histories.total_over_time,
|
198
|
+
|
199
|
+
obc_work_histories.paid_recess_time,
|
200
|
+
|
201
|
+
obc_work_histories.note,
|
202
|
+
|
203
|
+
obc_work_histories.created_user,
|
204
|
+
|
205
|
+
obc_work_histories.created_datetime,
|
206
|
+
|
207
|
+
obc_work_histories.modified_user,
|
208
|
+
|
209
|
+
obc_work_histories.modified_datetime,
|
210
|
+
|
211
|
+
obc_work_histories.leave_desk_1_datetime,
|
212
|
+
|
213
|
+
obc_work_histories.arrive_desk_1_datetime,
|
214
|
+
|
215
|
+
obc_work_histories.leave_desk_2_datetime,
|
216
|
+
|
217
|
+
obc_work_histories.arrive_desk_2_datetime,
|
218
|
+
|
219
|
+
obc_work_histories.work_start_time + '00:01:00'::interval *
|
220
|
+
|
221
|
+
CASE date_part('minutes'::text, obc_work_histories.work_start_time)::integer % 15
|
222
|
+
|
223
|
+
WHEN 0 THEN 0
|
224
|
+
|
225
|
+
ELSE 15 - date_part('minutes'::text, obc_work_histories.work_start_time)::integer % 15
|
226
|
+
|
227
|
+
END::double precision AS managed_work_start_time,
|
228
|
+
|
229
|
+
obc_work_histories.work_end_time AS managed_work_end_time
|
230
|
+
|
231
|
+
FROM obc_work_histories
|
232
|
+
|
233
|
+
)
|
234
|
+
|
235
|
+
SELECT owh.id,
|
236
|
+
|
237
|
+
owh.mt_employee_id,
|
238
|
+
|
239
|
+
owh.work_day,
|
240
|
+
|
241
|
+
owh.shift_pattern_id,
|
242
|
+
|
243
|
+
owh.mt_work_reason_id,
|
244
|
+
|
245
|
+
owh.work_start_time,
|
246
|
+
|
247
|
+
owh.work_end_time,
|
248
|
+
|
249
|
+
owh.reces_time,
|
250
|
+
|
251
|
+
owh.normal_working_time,
|
252
|
+
|
253
|
+
owh.daytime_over_time,
|
254
|
+
|
255
|
+
owh.midnight_over_time,
|
256
|
+
|
257
|
+
owh.total_over_time,
|
258
|
+
|
259
|
+
owh.paid_recess_time,
|
260
|
+
|
261
|
+
owh.note,
|
262
|
+
|
263
|
+
owh.created_user,
|
264
|
+
|
265
|
+
owh.created_datetime,
|
266
|
+
|
267
|
+
owh.modified_user,
|
268
|
+
|
269
|
+
owh.modified_datetime,
|
270
|
+
|
271
|
+
owh.leave_desk_1_datetime,
|
272
|
+
|
273
|
+
owh.arrive_desk_1_datetime,
|
274
|
+
|
275
|
+
owh.leave_desk_2_datetime,
|
276
|
+
|
277
|
+
owh.arrive_desk_2_datetime,
|
278
|
+
|
279
|
+
owh.managed_work_start_time,
|
280
|
+
|
281
|
+
owh.managed_work_end_time,
|
282
|
+
|
283
|
+
owh.arrive_desk_1_datetime - owh.leave_desk_1_datetime AS outing_1_time,
|
284
|
+
|
285
|
+
owh.arrive_desk_2_datetime - owh.leave_desk_2_datetime AS outing_2_time,
|
286
|
+
|
287
|
+
owh.managed_work_end_time - owh.managed_work_start_time - (owh.arrive_desk_1_datetime - owh.leave_desk_1_datetime) - (owh.arrive_desk_2_datetime - owh.leave_desk_2_datetime) AS actual_working_times
|
288
|
+
|
289
|
+
FROM owh;
|
290
|
+
|
291
|
+
```
|