use of com.qcadoo.mes.productionLines.controller.dataProvider.ShiftWorkingDateResponse in project mes by qcadoo.
the class ProductionLinesApiController method getShiftWorkingDate.
@ResponseBody
@RequestMapping(value = "/productionLine/{productionLineId}/shiftWorkingDate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ShiftWorkingDateResponse getShiftWorkingDate(@PathVariable Long productionLineId, @RequestParam("date") Date date) {
Entity productionLineEntity = dataDefinitionService.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_PRODUCTION_LINE).get(productionLineId);
Optional<Shift> maybeShift = shiftsService.getShiftForNearestWorkingDate(new DateTime(date), productionLineEntity);
return maybeShift.map(shift -> new ShiftWorkingDateResponse(shift.getShiftStartDate().toDate(), shift.getShiftEndDate().toDate())).orElseGet(() -> new ShiftWorkingDateResponse(ShiftWorkingDateResponse.StatusCode.ERROR));
}
Aggregations