Class BTInterventionOutcomeSave
java.lang.Object
overit.geocall.bl.BusinessTask<InterventionOutcomeSaveEvent>
overit.geocallapp.wfm.orchestrator.workorders.bl.outcome.intervention.task.BTInterventionOutcomeSave
- All Implemented Interfaces:
Serializable,Tool
@Event(InterventionOutcomeSaveEvent.class)
public class BTInterventionOutcomeSave
extends BusinessTask<InterventionOutcomeSaveEvent>
Business task in order to save an
When the
The
BOInterventionOutcome. When the
InterventionOutcomeSaveEvent is launched
the BT notices the call and saves the BOInterventionOutcome basing on the event's input. The
BOInterventionOutcome saving process divide itself into multiple steps:
- validation phase using
InterventionOutcomeValidateEvent - check on the existence of related interventions that are already accounted
- check on the intervention measures to ensure they are all validated
- if the intervention is not already closed, it updates also the related appointment, work order operation and work order
- if the intervention is already closed, only few information are allowed to be updated
Required fields:
- intervention id
- outcome origin
- outcome reason
Error code:
- Since:
- 18.0
- See Also:
- GCApi:
- task
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BOAppointmentprotected InterventionAggregateprotected BOOutcomeReasonprotected BOWorkOrderHeaderprotected BOWorkOrderOperation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbody(InterventionOutcomeSaveEvent event, PoolKit poolKit) Saves theBOInterventionOutcome.protected voidcheckAlreadyAccountedIntervention(List<InterventionAggregate> sameAppointmentIntervention) Checks if the intervention is related to another already accounted intervention.protected voidcheckMeasures(BOIntervention intervention, PoolKit poolKit) Validates the measures for the intervention outcome by calling theInterventionMeasureCheckEvent.protected voidcheckMeterReadings(Long reasonTypeId, Long interventionGroup, PoolKit poolKit) Checks if the meter readings are mandatory for this outcome.protected booleancheckTotalOutcomesForWorkOrder(BOWorkOrderHeader workOrder, BOWorkOrderOperation workOrderOperation, PoolKit poolKit) Checks if the total outcomes for the work order is being respected or not.protected voidChecks whether the work order operation status is valid for the intervention outcome saving.protected LonggetForcedClosureType(BOWorkOrderHeader workOrder, Long outcomeType, BOWorkOrderOperation workOrderOperation, boolean isLastAppointment, PoolKit poolKit) Returns the forced closure type basing on the outcome data.protected WorkOrdersIntegrationServicegetIntegrationService(PoolKit poolKit) Returns the integration service.protected LonggetInterventionGroup(PoolKit poolKit) Returns the intervention group.protected LonggetResidualTime(BOWorkOrderOperation workOrderOperation, List<InterventionAggregate> sameAppointmentIntervention, boolean isLastAppointment) Calculates the work order operation residual time.protected List<InterventionAggregate> getSameAppointmentInterventions(PoolKit poolKit) Returns the all the interventions that have the same appointment of the intervention we are saving.protected LonggetWorkOrderOperationStatus(BOWorkOrderOperation workOrderOperation, Long outcomeType, PoolKit poolKit) Returns the calculated work order operation status.protected voidinitialize(InterventionOutcomeSaveInput input, PoolKit poolKit) Initializes the needed entity for the saving.protected voidinsertInterventionOutcome(boolean isLastAppointment, Long outcomeType, PoolKit poolKit) Inserts the new intervention outcome.protected booleanisLastAppointment(List<InterventionAggregate> sameAppointmentIntervention) Checks if the intervention appointment is last one for the given work order operation.protected BOAppointmentloadAppointment(Long appointment, PoolKit poolKit) Loads the appointment.protected InterventionAggregateloadInterventionAggregate(Long id, PoolKit poolKit) Loads theInterventionAggregate.protected BOOutcomeReasonloadOutcomeReason(Long outcomeReason, PoolKit poolKit) Loads the outcome reason from the given id.protected BOOutcomeReasonTypeloadReasonType(Long outcomeReasonType, PoolKit poolKit) Loads the reason type from the given id.protected BOWorkOrderHeaderloadWorkOrder(Long workOrder, PoolKit poolKit) Loads the work order from the given id.protected BOWorkOrderOperationloadWorkOrderOperation(Long workOrderOperation, PoolKit poolKit) Loads the work order operation from the given id.protected voidnotifyInterventionOutcome(InterventionOutcomeNotificationAction action, boolean isLastAppointment, Long outcomeType, Date limitDate, PoolKit poolKit) Notifies the intervention outcome update.protected voidrecalculateWorkOrderStatus(PoolKit poolKit) Recalculates the work order status by calling theWorkOrderHeaderStatusRecalculateEvent.protected List<BOWorkOrderOperation> searchWorkOrderOperations(PoolKit poolKit) Searches for the work order operations related to the given work order, sorting them by last outcome date.protected voidsetOutcomeEndDate(Date now) Sets the outcome end date basing on the intervention.protected voidsetOutcomeStartDate(List<InterventionAggregate> sameAppointmentIntervention, Date now) Sets the outcome start date basing on the intervention or the previously not yet accounted ones.protected voidSets the last outcome data on the work order operation.protected voidsetWorkOrderOperationResidualTime(List<InterventionAggregate> sameAppointmentIntervention, boolean isLastAppointment, Long outcomeType) Sets the work order operation residual time.protected voidupdateInterventionOutcome(PoolKit poolKit) Updates the current intervention outcome.protected voidupdateValidationStatus(PoolKit poolKit) Updates the validation status by calling theInterventionOutcomeValidationStatusUpdateEventand theInterventionOutcomeValidationStatusByRuleUpdateEvent.protected voidupdateWOByOrderInterventions(PoolKit poolKit) Updates all the intervention that have the current one as parent.protected voidupdateWorkOrder(PoolKit poolKit) Updates the work order and updates its status.protected voidupdateWorkOrderOperation(boolean isLastAppointment, Long outcomeType, List<InterventionAggregate> sameAppointmentIntervention, PoolKit poolKit) Updates the work order operation with its status.protected voidvalidate(InterventionOutcomeSaveInput input, PoolKit poolKit) Validates the outcome and the intervention before the saving process.Methods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
interventionAggregate
-
appointment
-
workOrderOperation
-
workOrder
-
outcomeReason
-
-
Constructor Details
-
BTInterventionOutcomeSave
public BTInterventionOutcomeSave()
-
-
Method Details
-
body
protected void body(InterventionOutcomeSaveEvent event, PoolKit poolKit) throws DAException, DAValidateException Saves theBOInterventionOutcome.- Specified by:
bodyin classBusinessTask<InterventionOutcomeSaveEvent>- Parameters:
event- theInterventionOutcomeSaveEventpoolKit- thePoolKit- Throws:
DAException- the DA exceptionDAValidateException- the DA validate exception
-
validate
protected void validate(InterventionOutcomeSaveInput input, PoolKit poolKit) throws DAValidateException, DAException Validates the outcome and the intervention before the saving process.- Parameters:
input- theInterventionOutcomeSaveInputpoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
updateWOByOrderInterventions
protected void updateWOByOrderInterventions(PoolKit poolKit) throws DAValidateException, DAException Updates all the intervention that have the current one as parent. Used in work order by order management.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
initialize
protected void initialize(InterventionOutcomeSaveInput input, PoolKit poolKit) throws DAValidateException, DAException Initializes the needed entity for the saving.- Parameters:
input- theInterventionOutcomeSaveInputpoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
checkAlreadyAccountedIntervention
protected void checkAlreadyAccountedIntervention(List<InterventionAggregate> sameAppointmentIntervention) throws DAValidateException Checks if the intervention is related to another already accounted intervention.- Parameters:
sameAppointmentIntervention- list ofInterventionAggregate- Throws:
DAValidateException- the DA validate exception
-
getSameAppointmentInterventions
protected List<InterventionAggregate> getSameAppointmentInterventions(PoolKit poolKit) throws DAValidateException, DAException Returns the all the interventions that have the same appointment of the intervention we are saving.- Parameters:
poolKit- thePoolKit- Returns:
- the same appointment interventions
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
setOutcomeStartDate
protected void setOutcomeStartDate(List<InterventionAggregate> sameAppointmentIntervention, Date now) Sets the outcome start date basing on the intervention or the previously not yet accounted ones.- Parameters:
sameAppointmentIntervention- list ofInterventionAggregatewith the same appointmentnow- the now moment expressed as date
-
setOutcomeEndDate
Sets the outcome end date basing on the intervention.- Parameters:
now- the now moment expressed as date
-
checkWorkOrderOperationStatus
Checks whether the work order operation status is valid for the intervention outcome saving.- Throws:
DAValidateException- the DA validate exception
-
checkMeterReadings
protected void checkMeterReadings(Long reasonTypeId, Long interventionGroup, PoolKit poolKit) throws DAValidateException, DAException Checks if the meter readings are mandatory for this outcome.- Parameters:
reasonTypeId- the currentBOOutcomeReasonTypeinterventionGroup- the intervention grouppoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
checkMeasures
protected void checkMeasures(BOIntervention intervention, PoolKit poolKit) throws DAValidateException, DAException Validates the measures for the intervention outcome by calling theInterventionMeasureCheckEvent.- Parameters:
intervention- the interventionpoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
getWorkOrderOperationStatus
protected Long getWorkOrderOperationStatus(BOWorkOrderOperation workOrderOperation, Long outcomeType, PoolKit poolKit) throws DAValidateException, DAException Returns the calculated work order operation status.- Parameters:
workOrderOperation- the work order operationoutcomeType- the outcome typepoolKit- thePoolKit- Returns:
- the work order operation status
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
getForcedClosureType
protected Long getForcedClosureType(BOWorkOrderHeader workOrder, Long outcomeType, BOWorkOrderOperation workOrderOperation, boolean isLastAppointment, PoolKit poolKit) throws DAValidateException, DAException Returns the forced closure type basing on the outcome data.- Parameters:
workOrder- the work orderoutcomeType- the outcome typeworkOrderOperation- the work order operationisLastAppointment- is this the last appointmentpoolKit- thePoolKit- Returns:
- the forced closure type
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
checkTotalOutcomesForWorkOrder
protected boolean checkTotalOutcomesForWorkOrder(BOWorkOrderHeader workOrder, BOWorkOrderOperation workOrderOperation, PoolKit poolKit) throws DAValidateException, DAException Checks if the total outcomes for the work order is being respected or not.- Parameters:
workOrder- the work orderworkOrderOperation- the work order operationpoolKit- thePoolKit- Returns:
- true if the outcome count for the work order is respected, false otherwise
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
insertInterventionOutcome
protected void insertInterventionOutcome(boolean isLastAppointment, Long outcomeType, PoolKit poolKit) throws DAValidateException, DAException Inserts the new intervention outcome. Please note that inserting an intervention outcome translates into updating the AAGENDA db table.- Parameters:
isLastAppointment- is this the last appointmentoutcomeType- the outcome typepoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
updateInterventionOutcome
Updates the current intervention outcome.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
notifyInterventionOutcome
protected void notifyInterventionOutcome(InterventionOutcomeNotificationAction action, boolean isLastAppointment, Long outcomeType, Date limitDate, PoolKit poolKit) throws DAValidateException, DAException Notifies the intervention outcome update.- Parameters:
action- the action performed on the intervention outcomeisLastAppointment- is this the last appointmentoutcomeType- the outcome typelimitDate- the limit datepoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
updateWorkOrder
Updates the work order and updates its status.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
searchWorkOrderOperations
protected List<BOWorkOrderOperation> searchWorkOrderOperations(PoolKit poolKit) throws DAValidateException, DAException Searches for the work order operations related to the given work order, sorting them by last outcome date.- Parameters:
poolKit- thePoolKit- Returns:
- a list of loaded work order operation
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
recalculateWorkOrderStatus
Recalculates the work order status by calling theWorkOrderHeaderStatusRecalculateEvent.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
setWorkOrderOperationLastOutcomeData
protected void setWorkOrderOperationLastOutcomeData()Sets the last outcome data on the work order operation. -
updateValidationStatus
Updates the validation status by calling theInterventionOutcomeValidationStatusUpdateEventand theInterventionOutcomeValidationStatusByRuleUpdateEvent.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
updateWorkOrderOperation
protected void updateWorkOrderOperation(boolean isLastAppointment, Long outcomeType, List<InterventionAggregate> sameAppointmentIntervention, PoolKit poolKit) throws DAValidateException, DAException Updates the work order operation with its status.- Parameters:
isLastAppointment- is this the last appointmentoutcomeType- the outcome typesameAppointmentIntervention- list ofInterventionAggregatewith the same appointmentpoolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
setWorkOrderOperationResidualTime
protected void setWorkOrderOperationResidualTime(List<InterventionAggregate> sameAppointmentIntervention, boolean isLastAppointment, Long outcomeType) Sets the work order operation residual time.- Parameters:
sameAppointmentIntervention- list ofInterventionAggregateisLastAppointment- the is last appointmentoutcomeType- the outcome type
-
getResidualTime
protected Long getResidualTime(BOWorkOrderOperation workOrderOperation, List<InterventionAggregate> sameAppointmentIntervention, boolean isLastAppointment) Calculates the work order operation residual time.- Parameters:
workOrderOperation- the current work order operationsameAppointmentIntervention- list ofInterventionAggregateisLastAppointment- is this the last appointment- Returns:
- the residual time
-
loadInterventionAggregate
protected InterventionAggregate loadInterventionAggregate(Long id, PoolKit poolKit) throws DAValidateException, DAException Loads theInterventionAggregate.- Parameters:
id- the intervention idpoolKit- thePoolKit- Returns:
- the loaded intervention aggregate
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
loadAppointment
protected BOAppointment loadAppointment(Long appointment, PoolKit poolKit) throws DAValidateException, DAException Loads the appointment.- Parameters:
appointment- the appointmentpoolKit- the poolPoolKit- Returns:
- the loaded appointment
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
loadWorkOrderOperation
protected BOWorkOrderOperation loadWorkOrderOperation(Long workOrderOperation, PoolKit poolKit) throws DAValidateException, DAException Loads the work order operation from the given id.- Parameters:
workOrderOperation- the work order operation idpoolKit- thePoolKit- Returns:
- the loaded work order operation
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
loadWorkOrder
protected BOWorkOrderHeader loadWorkOrder(Long workOrder, PoolKit poolKit) throws DAValidateException, DAException Loads the work order from the given id.- Parameters:
workOrder- the work order idpoolKit- thePoolKit- Returns:
- the loaded work order header
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
loadOutcomeReason
protected BOOutcomeReason loadOutcomeReason(Long outcomeReason, PoolKit poolKit) throws DAValidateException, DAException Loads the outcome reason from the given id.- Parameters:
outcomeReason- the outcome reason idpoolKit- thePoolKit- Returns:
- the loaded outcome reason
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
loadReasonType
protected BOOutcomeReasonType loadReasonType(Long outcomeReasonType, PoolKit poolKit) throws DAValidateException, DAException Loads the reason type from the given id.- Parameters:
outcomeReasonType- the outcome reason type idpoolKit- thePoolKit- Returns:
- the loaded outcome reason type
- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
isLastAppointment
Checks if the intervention appointment is last one for the given work order operation.- Parameters:
sameAppointmentIntervention- list ofInterventionAggregate- Returns:
- true if the appointment is the last one for the given intervention
-
getInterventionGroup
Returns the intervention group.- Parameters:
poolKit- thePoolKit- Returns:
- the intervention group
- Throws:
DAValidateException- the DA validate exceptionDAException
-
getIntegrationService
protected WorkOrdersIntegrationService getIntegrationService(PoolKit poolKit) throws DAValidateException Returns the integration service.- Parameters:
poolKit- thePoolKit- Returns:
- the integration service
- Throws:
DAValidateException- the DA validate exception
-