Search in sources :

Example 1 with ShiftWorkingDateResponse

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));
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) LocaleContextHolder(org.springframework.context.i18n.LocaleContextHolder) PathVariable(org.springframework.web.bind.annotation.PathVariable) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) RequestParam(org.springframework.web.bind.annotation.RequestParam) ShiftsService(com.qcadoo.mes.basic.ShiftsService) Date(java.util.Date) ProductionLineFields(com.qcadoo.mes.productionLines.constants.ProductionLineFields) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ProductionLinesConstants(com.qcadoo.mes.productionLines.constants.ProductionLinesConstants) Controller(org.springframework.stereotype.Controller) Shift(com.qcadoo.mes.basic.shift.Shift) RequestBody(org.springframework.web.bind.annotation.RequestBody) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) ShiftWorkingDateResponse(com.qcadoo.mes.productionLines.controller.dataProvider.ShiftWorkingDateResponse) ProductionLineDto(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineDto) ProductionLinesDataProvider(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesDataProvider) ProductionLineResponse(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineResponse) MediaType(org.springframework.http.MediaType) DateTime(org.joda.time.DateTime) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) TranslationService(com.qcadoo.localization.api.TranslationService) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Objects(java.util.Objects) Entity(com.qcadoo.model.api.Entity) ProductionLinesResponse(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesResponse) Optional(java.util.Optional) ProductionLineRequest(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineRequest) ProductionLinesGridResponse(com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesGridResponse) Entity(com.qcadoo.model.api.Entity) ShiftWorkingDateResponse(com.qcadoo.mes.productionLines.controller.dataProvider.ShiftWorkingDateResponse) DateTime(org.joda.time.DateTime) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TranslationService (com.qcadoo.localization.api.TranslationService)1 ShiftsService (com.qcadoo.mes.basic.ShiftsService)1 Shift (com.qcadoo.mes.basic.shift.Shift)1 ProductionLineFields (com.qcadoo.mes.productionLines.constants.ProductionLineFields)1 ProductionLinesConstants (com.qcadoo.mes.productionLines.constants.ProductionLinesConstants)1 ProductionLineDto (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineDto)1 ProductionLineRequest (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineRequest)1 ProductionLineResponse (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLineResponse)1 ProductionLinesDataProvider (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesDataProvider)1 ProductionLinesGridResponse (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesGridResponse)1 ProductionLinesResponse (com.qcadoo.mes.productionLines.controller.dataProvider.ProductionLinesResponse)1 ShiftWorkingDateResponse (com.qcadoo.mes.productionLines.controller.dataProvider.ShiftWorkingDateResponse)1 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)1 Entity (com.qcadoo.model.api.Entity)1 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)1 Date (java.util.Date)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 DateTime (org.joda.time.DateTime)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1