Skip to content

Commit

Permalink
add set sudah keluar semua
Browse files Browse the repository at this point in the history
update api untuk take snapshot
  • Loading branch information
udibagas committed Oct 1, 2019
1 parent c087366 commit 2b4a4d0
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/ParkingGateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ public function takeSnapshot(ParkingGate $parkingGate)
$parkingGate->camera_auth_type == 'digest' ? 'digest' : null
]
]);
file_put_contents($fileName, $response->getBody());

if ($response->getHeader('Content-Type') == 'image/jpeg') {
file_put_contents($fileName, $response->getBody());
} else {
return response(['message' => 'GAGAL MENGAMBIL GAMBAR. URL SNAPSHOT KAMERA TIDAK SESUAI'], 500);
}
} catch (\Exception $e) {
return response(['message' => 'GAGAL MENGAMBIL GAMBAR. '. $e->getMessage()], 500);
}
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/ParkingTransactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,21 @@ public function destroy(ParkingTransaction $parkingTransaction)
public function setSudahKeluar(ParkingTransaction $parkingTransaction)
{
$parkingTransaction->time_out = now();
$parkingTransaction->operator = auth()->user()->name;
$parkingTransaction->save();
return ['message' => 'KENDARAAN BERHASIL DISET SUDAH KELUAR'];
}

public function setSudahKeluarSemua(Request $request)
{
ParkingTransaction::whereRaw('time_out IS NULL AND DATE(time_in) BETWEEN :start AND :stop', [
':start' => $request->dateRange[0],
':stop' => $request->dateRange[1]
])->update([
'time_out' => now(),
'operator' => $request->user()->name
]);

return ['message' => 'KENDARAAN BERHASIL DISET SUDAH KELUAR'];
}
}
12 changes: 9 additions & 3 deletions parking.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,24 @@ def get_gates():

def take_snapshot(gate):
if gate['camera_status'] == 0:
logging.info(gate['name'] + ' : Not taking snapshot. Camera not active')
return ''

try:
r = requests.get(API_URL + '/parkingGate/takeSnapshot/' + str(gate['id']))

if r.status_code != 200:
logging.error(gate['name'] + ' : Failed to take snapshot. Status code : ' + r.status_code)
send_notification(gate, "Gagal mengambil snapshot di gate " + gate['name'] + ". Status Code : " + r.status_code)
return ''

respons = r.json()
return respons['filename']
except Exception as e:
logging.error(gate['name'] + ' : Failed to take snapshot ' + str(e))
send_notification(gate, "Gagal mengambil snapshot di gate " + gate['name'] + " (" + str(e) + ")")
return ''

respons = r.json()
return respons['filename']

def generate_barcode_number():
return ''.join([random.choice(string.ascii_uppercase + string.digits) for n in range(5)])

Expand Down
5 changes: 5 additions & 0 deletions parking.service
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# taruh di /etc/systemd/system
# systemctl daemon-reload
# systemctl enable parking
# systemctl start parking

[Unit]
Description=Parking controller service
Requires=network.target
Expand Down
24 changes: 23 additions & 1 deletion resources/js/pages/ParkingTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
end-placeholder="End date">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-finished" @click="setSudahKeluarSemua">SET KENDARAAN SUDAH KELUAR SEMUA</el-button>
</el-form-item>
<el-form-item style="margin-right:0;">
<el-input v-model="keyword" placeholder="Search" prefix-icon="el-icon-search" :clearable="true" @change="(v) => { keyword = v; requestData(); }">
<el-button @click="() => { page = 1; keyword = ''; requestData(); }" slot="append" icon="el-icon-refresh"></el-button>
Expand Down Expand Up @@ -137,7 +140,7 @@ export default {
income: [],
parkedVehicle: [],
date: moment().format('YYYY-MM-DD'),
dateRange: [moment().format('YYYY-MM-01'), moment().format('YYYY-MM-DD')]
dateRange: [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
}
},
methods: {
Expand All @@ -154,6 +157,25 @@ export default {
type: 'success',
showClose: true
});
this.requestData()
}).catch(e => {
this.$message({
message: r.response.data.message,
type: 'error',
showClose: true
});
})
}).catch(() => console.log(e))
},
setSudahKeluarSemua() {
this.$confirm('Anda yakin?', 'Confirm', { type: 'warning' }).then(() => {
axios.put('parkingTransaction/setSudahKeluarSemua', { dateRange: this.dateRange }).then(r => {
this.$message({
message: r.data.message,
type: 'success',
showClose: true
});
this.requestData()
}).catch(e => {
this.$message({
message: r.response.data.message,
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Route::resource('groupMember', 'GroupMemberController')->except(['create', 'edit', 'show']);
Route::post('parkingTransaction/takeSnapshot/{parkingTransaction}', 'ParkingTransactionController@takeSnapshot');
Route::post('parkingTransaction/printTicket/{parkingTransaction}', 'ParkingTransactionController@printTicket');
Route::put('parkingTransaction/setSudahKeluarSemua', 'ParkingTransactionController@setSudahKeluarSemua');
Route::put('parkingTransaction/setSudahKeluar/{parkingTransaction}', 'ParkingTransactionController@setSudahKeluar');
Route::get('parkingTransaction/search', 'ParkingTransactionController@search');
Route::resource('parkingTransaction', 'ParkingTransactionController')->except(['create', 'edit']);
Expand Down

0 comments on commit 2b4a4d0

Please sign in to comment.