Commit 20fac9b7 authored by Xenia Ulyanova's avatar Xenia Ulyanova
Browse files

clean up

parent 4f187a61
Showing with 249 additions and 385 deletions
+249 -385
......@@ -6,23 +6,23 @@ import com.cdek.warehouse.services.WarehouseServiceException;
* Исключения для Сервисов коррекции ПГМ
*/
public class CorrectionException extends WarehouseServiceException {
public CorrectionException(String key) {
super(key);
}
public CorrectionException(String key) {
super(key);
}
public CorrectionException(String key, String message) {
super(key, message);
}
public CorrectionException(String key, String message) {
super(key, message);
}
public CorrectionException(String key, String message, Throwable cause) {
super(key, message, cause);
}
public CorrectionException(String key, String message, Throwable cause) {
super(key, message, cause);
}
public CorrectionException(String key, Throwable cause) {
super(key, cause);
}
public CorrectionException(String key, Throwable cause) {
super(key, cause);
}
public CorrectionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, String key) {
super(message, cause, enableSuppression, writableStackTrace, key);
}
public CorrectionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, String key) {
super(message, cause, enableSuppression, writableStackTrace, key);
}
}
......@@ -2,14 +2,11 @@ package com.cdek.warehouse.services.correction;
import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.document.correction.CorrectionIncome;
import com.cdek.transport.model.document.correction.CorrectionShipment;
import com.cdek.transport.model.document.correction.VerifyResult;
import java.util.Date;
import java.util.List;
/**
* Класс управляет процессом коррекции.
* Документация
* Предварительные проверки
* Создание Документов Коррекции, заполнение документов коррекции.
* Отправка запроса на списание на другой Инст
......@@ -17,51 +14,37 @@ import java.util.List;
public interface CorrectionManager {
/**
* Обрабатывает результат списание ГМ с другого филиала.
*
* @param response
*/
void handleCorrectionResponse(CorrectionResult response);
/**
* Обрабатывает запрос на списание ГМ с филиала.
*
* @param request
*/
void handleCorrectionRequest(CorrectionRequest request);
/**
* Проверки, что для данного ПГМ возможны коррекционные мероприятия.
* См. документацию список проверок
* @param cargoPlaceUuid идентификатор ПГМ
* @param branchTo код филиала, куда планируется перевести ПГМ
*/
VerifyResult verifyCorrection(String cargoPlaceUuid, String branchTo) throws CorrectionException;
/**
* Добавляет Грузоместо в Документ Коррекции, проводит все этапы коррекции
*
* @param correctionIncome
* @param cargoPlace
* @param userCode
*/
void performCorrection(CorrectionIncome correctionIncome, CargoPlace cargoPlace, String userCode) throws CorrectionException;
/**
* Расходует ПГМ на филиале, добавляет ПГМ в Документ Расход-Коррекция.
* При необходимости удаляет из Консолидации (Отправки) {@link com.cdek.transport.model.operation.ForceCargoPlaceDeletion}
* В итоге ПГМ не активно, внесено в Расход-Коррекцию, текущий склад и филиал сброшены.
* ПГМ готово к внесению в Документ Приход-Коррекция на другом филиале.
* @param correctionShipment
* @param cargoPlace
* @param documentNumbers номера затронутых документов, например, документа Приход-Коррекция
* @param userCode
*
* @return идентификатор выполненной операции добавления в документ Расход-Коррекция
*/
//CorrectionShipmentResult makeShipment(CorrectionShipment correctionShipment, CargoPlace cargoPlace, List<String> documentNumbers, String userCode);
/**
* Обрабатывает результат списание ГМ с другого филиала.
*
* @param response
*/
void handleCorrectionResponse(CorrectionResult response);
/**
* Обрабатывает запрос на списание ГМ с филиала.
*
* @param request
*/
void handleCorrectionRequest(CorrectionRequest request);
/**
* Проверки, что для данного ПГМ возможны коррекционные мероприятия.
* См. документацию список проверок
*
* @param cargoPlaceUuid идентификатор ПГМ
* @param branchTo код филиала, куда планируется перевести ПГМ
*/
VerifyResult verifyCorrection(String cargoPlaceUuid, String branchTo) throws CorrectionException;
/**
* Добавляет Грузоместо в Документ Коррекции, проводит все этапы коррекции
*
* @param correctionIncome
* @param cargoPlace
* @param userCode
*/
void performCorrection(CorrectionIncome correctionIncome, CargoPlace cargoPlace, String userCode) throws CorrectionException;
}
......@@ -11,18 +11,18 @@ import org.springframework.util.Assert;
* Отправляется по шине {@link com.cdek.warehouse.services.bus.MessageBus}
*/
public class CorrectionRequest {
/**
* Операция "попытка списания"
*/
private CorrectionAttempt correctionAttempt;
/**
* Операция "попытка списания"
*/
private CorrectionAttempt correctionAttempt;
public CorrectionRequest(CorrectionAttempt correctionAttempt) {
Assert.state(OperationStatus.EXECUTED == correctionAttempt.getStatus(), "correction attempt must be executed before request");
Assert.state(CorrectionAttemptResult.HANDLING == correctionAttempt.getResult(), "correction attempt must be in handling state");
this.correctionAttempt = correctionAttempt;
}
public CorrectionRequest(CorrectionAttempt correctionAttempt) {
Assert.state(OperationStatus.EXECUTED == correctionAttempt.getStatus(), "correction attempt must be executed before request");
Assert.state(CorrectionAttemptResult.HANDLING == correctionAttempt.getResult(), "correction attempt must be in handling state");
this.correctionAttempt = correctionAttempt;
}
public CorrectionAttempt getCorrectionAttempt() {
return correctionAttempt;
}
public CorrectionAttempt getCorrectionAttempt() {
return correctionAttempt;
}
}
......@@ -12,108 +12,108 @@ import java.util.List;
public class CorrectionResult {
/**
* Uuid операции попытки коррекции
*/
private String correctionAttemptUuid;
/**
* Операция добавления в документ Расход-Коррекция
* Содержит информацию о выполнении запроса на списание
*/
private CargoPlaceAdding correctionShipmentFilling;
/**
* Номер документа Консолидации, если был задействован в процессе списания с филиала
*/
private String consolidationNumber;
/**
* Номер документа Расход-Коррекция, который был задействован в процессе списания с филиала
*/
private String correctionShipmentNumber;
/**
* Номер документа Выдача на доставку, который был задействован в процессе списания с филиала
*/
private String deliveryNumber;
/**
* Флаг наличия ошибок при коррекции на другом филиале, которые возникли еще до добавления в Расход-Коррекцию.
* Ошибка в процессе внесения ПГМ в Расход-Коррекцию содержится в самой операции {@link this#correctionShipmentFilling}
*/
private boolean hasError;
private String errorCode;
public CargoPlaceAdding getCorrectionShipmentFilling() {
return correctionShipmentFilling;
}
public void setCorrectionShipmentFilling(CargoPlaceAdding correctionShipmentFilling) {
this.correctionShipmentFilling = correctionShipmentFilling;
}
public String getConsolidationNumber() {
return consolidationNumber;
}
public void setConsolidationNumber(String consolidationNumber) {
this.consolidationNumber = consolidationNumber;
}
public String getCorrectionShipmentNumber() {
return correctionShipmentNumber;
}
public void setCorrectionShipmentNumber(String correctionShipmentNumber) {
this.correctionShipmentNumber = correctionShipmentNumber;
}
public String getDeliveryNumber() {
return deliveryNumber;
}
public void setDeliveryNumber(String deliveryNumber) {
this.deliveryNumber = deliveryNumber;
}
public List<String> getDocumentNumbers(){
List<String> numbers = new ArrayList<>();
if(StringUtils.isNotBlank(getConsolidationNumber())){
numbers.add(getConsolidationNumber());
}
if(StringUtils.isNotBlank(getCorrectionShipmentNumber())){
numbers.add(getCorrectionShipmentNumber());
}
if(StringUtils.isNotBlank(getDeliveryNumber())){
numbers.add(getDeliveryNumber());
}
return numbers;
}
public void setCorrectionAttemptUuid(String correctionAttemptUuid) {
this.correctionAttemptUuid = correctionAttemptUuid;
}
public String getCorrectionAttemptUuid() {
return correctionAttemptUuid;
}
public boolean hasError() {
return hasError;
}
public void setHasError(boolean hasError) {
this.hasError = hasError;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
/**
* Uuid операции попытки коррекции
*/
private String correctionAttemptUuid;
/**
* Операция добавления в документ Расход-Коррекция
* Содержит информацию о выполнении запроса на списание
*/
private CargoPlaceAdding correctionShipmentFilling;
/**
* Номер документа Консолидации, если был задействован в процессе списания с филиала
*/
private String consolidationNumber;
/**
* Номер документа Расход-Коррекция, который был задействован в процессе списания с филиала
*/
private String correctionShipmentNumber;
/**
* Номер документа Выдача на доставку, который был задействован в процессе списания с филиала
*/
private String deliveryNumber;
/**
* Флаг наличия ошибок при коррекции на другом филиале, которые возникли еще до добавления в Расход-Коррекцию.
* Ошибка в процессе внесения ПГМ в Расход-Коррекцию содержится в самой операции {@link this#correctionShipmentFilling}
*/
private boolean hasError;
private String errorCode;
public CargoPlaceAdding getCorrectionShipmentFilling() {
return correctionShipmentFilling;
}
public void setCorrectionShipmentFilling(CargoPlaceAdding correctionShipmentFilling) {
this.correctionShipmentFilling = correctionShipmentFilling;
}
public String getConsolidationNumber() {
return consolidationNumber;
}
public void setConsolidationNumber(String consolidationNumber) {
this.consolidationNumber = consolidationNumber;
}
public String getCorrectionShipmentNumber() {
return correctionShipmentNumber;
}
public void setCorrectionShipmentNumber(String correctionShipmentNumber) {
this.correctionShipmentNumber = correctionShipmentNumber;
}
public String getDeliveryNumber() {
return deliveryNumber;
}
public void setDeliveryNumber(String deliveryNumber) {
this.deliveryNumber = deliveryNumber;
}
public List<String> getDocumentNumbers() {
List<String> numbers = new ArrayList<>();
if (StringUtils.isNotBlank(getConsolidationNumber())) {
numbers.add(getConsolidationNumber());
}
if (StringUtils.isNotBlank(getCorrectionShipmentNumber())) {
numbers.add(getCorrectionShipmentNumber());
}
if (StringUtils.isNotBlank(getDeliveryNumber())) {
numbers.add(getDeliveryNumber());
}
return numbers;
}
public void setCorrectionAttemptUuid(String correctionAttemptUuid) {
this.correctionAttemptUuid = correctionAttemptUuid;
}
public String getCorrectionAttemptUuid() {
return correctionAttemptUuid;
}
public boolean hasError() {
return hasError;
}
public void setHasError(boolean hasError) {
this.hasError = hasError;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
}
......@@ -12,41 +12,41 @@ import java.util.List;
*/
public class CorrectionShipmentResult {
private String shipmentNumber;
private String consolidationNumber;
private String deliveryNumber;
private String shipmentNumber;
private String consolidationNumber;
private String deliveryNumber;
private CargoPlaceAdding correctionShipmentFilling;
private CargoPlaceAdding correctionShipmentFilling;
public String getShipmentNumber() {
return shipmentNumber;
}
public String getShipmentNumber() {
return shipmentNumber;
}
public void setShipmentNumber(String shipmentNumber) {
this.shipmentNumber = shipmentNumber;
}
public void setShipmentNumber(String shipmentNumber) {
this.shipmentNumber = shipmentNumber;
}
public String getDeliveryNumber() {
return deliveryNumber;
}
public String getDeliveryNumber() {
return deliveryNumber;
}
public void setDeliveryNumber(String deliveryNumber) {
this.deliveryNumber = deliveryNumber;
}
public void setDeliveryNumber(String deliveryNumber) {
this.deliveryNumber = deliveryNumber;
}
public CargoPlaceAdding getCorrectionShipmentFilling() {
return correctionShipmentFilling;
}
public CargoPlaceAdding getCorrectionShipmentFilling() {
return correctionShipmentFilling;
}
public void setCorrectionShipmentFilling(CargoPlaceAdding correctionShipmentFilling) {
this.correctionShipmentFilling = correctionShipmentFilling;
}
public void setCorrectionShipmentFilling(CargoPlaceAdding correctionShipmentFilling) {
this.correctionShipmentFilling = correctionShipmentFilling;
}
public String getConsolidationNumber() {
return consolidationNumber;
}
public String getConsolidationNumber() {
return consolidationNumber;
}
public void setConsolidationNumber(String consolidationNumber) {
this.consolidationNumber = consolidationNumber;
}
public void setConsolidationNumber(String consolidationNumber) {
this.consolidationNumber = consolidationNumber;
}
}
......@@ -4,7 +4,7 @@ import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.document.correction.CorrectionIncome;
/**
*Стратегии для корректировки
* Стратегии для корректировки
*/
public interface LocalCorrection {
......
......@@ -10,21 +10,21 @@ import org.springframework.beans.factory.annotation.Required;
*/
public class CorrectionRequestHandler implements MessageHandler<CorrectionRequest> {
protected CorrectionManager correctionManager;
protected CorrectionManager correctionManager;
@Override
public void handle(CorrectionRequest message) {
correctionManager.handleCorrectionRequest(message);
}
@Override
public void handle(CorrectionRequest message) {
correctionManager.handleCorrectionRequest(message);
}
@Override
public Class<CorrectionRequest> getMessageClass() {
return CorrectionRequest.class;
}
@Override
public Class<CorrectionRequest> getMessageClass() {
return CorrectionRequest.class;
}
@Required
public void setCorrectionManager(CorrectionManager correctionManager) {
this.correctionManager = correctionManager;
}
@Required
public void setCorrectionManager(CorrectionManager correctionManager) {
this.correctionManager = correctionManager;
}
}
......@@ -10,20 +10,20 @@ import org.springframework.beans.factory.annotation.Required;
*/
public class CorrectionResponseHandler implements MessageHandler<CorrectionResult> {
protected CorrectionManager correctionManager;
protected CorrectionManager correctionManager;
@Override
public void handle(CorrectionResult message) {
correctionManager.handleCorrectionResponse(message);
}
@Override
public void handle(CorrectionResult message) {
correctionManager.handleCorrectionResponse(message);
}
@Override
public Class<CorrectionResult> getMessageClass() {
return CorrectionResult.class;
}
@Override
public Class<CorrectionResult> getMessageClass() {
return CorrectionResult.class;
}
@Required
public void setCorrectionManager(CorrectionManager correctionManager) {
this.correctionManager = correctionManager;
}
@Required
public void setCorrectionManager(CorrectionManager correctionManager) {
this.correctionManager = correctionManager;
}
}
......@@ -4,7 +4,9 @@ import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.document.Document;
import com.cdek.transport.model.document.DocumentType;
import com.cdek.transport.model.document.correction.CorrectionIncome;
import com.cdek.transport.model.operation.*;
import com.cdek.transport.model.operation.CargoPlaceAdding;
import com.cdek.transport.model.operation.ForceCargoPlaceDeletion;
import com.cdek.transport.model.operation.OperationStatus;
import com.cdek.warehouse.common.Messages;
import com.cdek.warehouse.services.CargoPlaceService;
import com.cdek.warehouse.services.correction.CorrectionException;
......@@ -21,7 +23,7 @@ import java.util.List;
import static com.cdek.transport.ek4.WarehouseConstants.SEMICOLON_DELIMITER;
/**
*
* Базовый класс для всех Локальных стратегий коррекции
*/
abstract public class BaseLocalCorrectionStrategy implements LocalCorrection {
......@@ -38,6 +40,7 @@ abstract public class BaseLocalCorrectionStrategy implements LocalCorrection {
/**
* Проводит "форсированное" удаление из документов Консолидации или Выдача на доставку
*
* @param cargoPlace
* @param document
*/
......
......@@ -31,16 +31,14 @@ import java.util.List;
import static com.cdek.transport.ek4.WarehouseConstants.SEMICOLON_DELIMITER;
/**
*
* Базовый класс для всех удаленных стратегий коррекции
*/
abstract public class BaseRemoteCorrectionStrategy {
private static final Logger LOGGER = LoggerFactory.getLogger(BaseRemoteCorrectionStrategy.class);
//??
protected DocumentService documentService;
protected ConsolidationService consolidationService;
//ok
protected ForceCargoPlaceDeletionService forceCargoPlaceDeletionService;
protected CorrectionShipmentCreateService correctionShipmentCreateService;
protected DocumentFillingService documentFillingService;
......@@ -152,6 +150,10 @@ abstract public class BaseRemoteCorrectionStrategy {
this.documentService = documentService;
}
public void setConsolidationService(ConsolidationService consolidationService) {
this.consolidationService = consolidationService;
}
@Required
public void setDocumentFillingService(DocumentFillingService documentFillingService) {
this.documentFillingService = documentFillingService;
......@@ -162,10 +164,6 @@ abstract public class BaseRemoteCorrectionStrategy {
this.forceCargoPlaceDeletionService = forceCargoPlaceDeletionService;
}
@Required
public void setConsolidationService(ConsolidationService consolidationService) {
this.consolidationService = consolidationService;
}
@Required
public void setSystemUserCode(String systemUserCode) {
......
......@@ -97,8 +97,9 @@ public abstract class BaseVerifyStrategy {
/**
* Проверяет принадлежность документа заданному филиалу
*
* @param document документ
* @param branch филиал
* @param branch филиал
* @return
*/
protected boolean isAtBranch(Document document, String branch) {
......
......@@ -9,22 +9,17 @@ import com.cdek.transport.model.operation.CorrectionAttempt;
import com.cdek.warehouse.services.correction.CorrectionException;
import com.cdek.warehouse.services.correction.CorrectionShipmentResult;
import com.cdek.warehouse.services.correction.RemoteCorrection;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static com.cdek.transport.ek4.WarehouseConstants.SEMICOLON_DELIMITER;
/**
* Коррекция на удаленном филиале для документа в Консолидации и Отправке
* Коррекция на удаленном филиале для ПГМ в документе Консолидации и Отправке
*/
public class ConsolidationRemoteCorrection extends BaseRemoteCorrectionStrategy implements RemoteCorrection {
private static final Logger LOGGER = LoggerFactory.getLogger(ConsolidationRemoteCorrection.class);
public class ConsolidationRemoteCorrectionStrategy extends BaseRemoteCorrectionStrategy implements RemoteCorrection {
private static final Logger LOGGER = LoggerFactory.getLogger(ConsolidationRemoteCorrectionStrategy.class);
@Override
public CorrectionShipmentResult execute(CorrectionAttempt correctionAttempt) throws CorrectionException {
......@@ -60,5 +55,4 @@ public class ConsolidationRemoteCorrection extends BaseRemoteCorrectionStrategy
return result;
}
}
......@@ -12,7 +12,6 @@ import com.cdek.transport.model.operation.*;
import com.cdek.warehouse.common.Messages;
import com.cdek.warehouse.dao.operation.CorrectionAttemptDAO;
import com.cdek.warehouse.services.CargoPlaceService;
import com.cdek.warehouse.services.CatalogsService;
import com.cdek.warehouse.services.WarehouseServiceException;
import com.cdek.warehouse.services.bus.MessageBus;
import com.cdek.warehouse.services.correction.*;
......@@ -33,7 +32,7 @@ import java.util.Map;
import static com.cdek.transport.ek4.WarehouseConstants.SEMICOLON_DELIMITER;
/**
* Сервис для операции коррекции.
* Сервис для проведения операций корректировки ПГМ
*/
public class CorrectionManagerImpl implements CorrectionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CorrectionManagerImpl.class);
......
......@@ -2,7 +2,6 @@ package com.cdek.warehouse.services.correction.impl;
import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.cargoplace.CargoPlaceStatus;
import com.cdek.transport.model.document.Consolidation;
import com.cdek.transport.model.document.DocumentRef;
import com.cdek.transport.model.document.correction.CorrectionShipment;
import com.cdek.transport.model.operation.CargoPlaceAdding;
......
......@@ -7,10 +7,8 @@ import com.cdek.transport.model.document.correction.IncomeActionType;
import com.cdek.transport.model.document.correction.VerifyResult;
import com.cdek.warehouse.common.Messages;
import com.cdek.warehouse.services.correction.IncomeVerifyStrategy;
import com.cdek.warehouse.services.document.DeliveryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
/**
* Верификатор для ГМ в документе Выдача на доставку {@link com.cdek.transport.model.document.Delivery}
......
......@@ -3,7 +3,6 @@ package com.cdek.warehouse.services.correction.impl;
import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.cargoplace.CargoPlaceStatus;
import com.cdek.transport.model.cargoplace.CargoPlaceType;
import com.cdek.transport.model.document.Document;
import com.cdek.transport.model.document.DocumentType;
import com.cdek.transport.model.document.correction.IncomeActionType;
import com.cdek.transport.model.document.correction.VerifyResult;
......@@ -13,11 +12,6 @@ import com.cdek.warehouse.services.CargoPlaceService;
import com.cdek.warehouse.services.WarehouseServiceException;
import com.cdek.warehouse.services.correction.IncomeVerifier;
import com.cdek.warehouse.services.correction.IncomeVerifyStrategy;
import com.cdek.warehouse.services.document.ConsolidationService;
import com.cdek.warehouse.services.document.DocumentService;
import com.cdek.warehouse.services.document.ShipmentService;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
......@@ -31,12 +25,7 @@ import java.util.Map;
*/
public class IncomeVerifierImpl implements IncomeVerifier {
private DocumentService documentService;
private ConsolidationService consolidationService;
private ShipmentService shipmentService;
private CargoPlaceService cargoPlaceService;
private Map<DocumentType, IncomeVerifyStrategy> verifyStrategyMap = new HashMap<>();
private static final Logger LOGGER = LoggerFactory.getLogger(IncomeVerifierImpl.class);
......@@ -70,11 +59,6 @@ public class IncomeVerifierImpl implements IncomeVerifier {
//статус найден, заполняем информацию о складе и филиале
fillResultWithStatusInfo(result, status);
// if (cargoPlaceAlreadyInBranch(branchTo, status.getCurrentBranch(), result)) {
// return result;
// }
/*2 ПГМ найдено (было рождено), но после было удалено из Первичного Прихода (неактивно, документ сброшен, и т.д.)
* Ошибка-блокер, внесение ПГМ невозможно
*/
......@@ -98,33 +82,9 @@ public class IncomeVerifierImpl implements IncomeVerifier {
result.addError(Messages.CORRECTION_ERROR, IncomeActionType.ILLEGAL_STATE);
return result;
/*
* 9.1 ПГМ в Консолидации. Последний документ у КГМ Расконсолидация.
* Расконсолидация в другом филиале
* Не важно, закрыта или нет.
* Проводим корректировку
* 9.2 Расконсолидация в текущем филиале.
* a) Если открыта - Ошибка-Блокер. Следует внести ПГМ в Расконсолидацию стандартным способом. (сообщить номер документа)
* b) Расконсолидация в текущем филиале закрыта - проводим корректировку (без расхода-коррекции, сразу приход-коррекция)
*/
// if (isLastDocumentDeconsolidation(status)) {
// verifyDeconsolidation(status, result, branchTo);
// }
}
protected boolean cargoPlaceAlreadyInBranch(String destinationBranch, String cargoPlaceBranch, VerifyResult result) {
if (StringUtils.equals(destinationBranch, cargoPlaceBranch)) {
LOGGER.warn("cargo place already belongs to this branch");
result.addError(Messages.CARGO_PLACE_ALREADY_IN_THIS_BRANCH);
return true;
}
return false;
}
protected void fillResultWithStatusInfo(VerifyResult result, CargoPlaceStatus status) {
result.setWarehouseCode(status.getCurrentWarehouse());
result.setBranchCode(status.getCurrentBranch());
......@@ -132,53 +92,6 @@ public class IncomeVerifierImpl implements IncomeVerifier {
result.setDocumentType(status.getDocumentType());
}
private void verifyDeconsolidation(CargoPlaceStatus status, VerifyResult result, String currentBranch) {
/*
* * 9.1 ПГМ в Консолидации. Последний документ у КГМ Расконсолидация.
* Расконсолидация в другом филиале
* Не важно, закрыта или нет.
* Проводим корректировку
* 9.2 Расконсолидация в текущем филиале.
* a) Если открыта - Ошибка-Блокер. Следует внести ПГМ в Расконсолидацию стандартным способом. (сообщить номер документа)
* b) Расконсолидация в текущем филиале закрыта - проводим корректировку (без расхода-коррекции, сразу приход-коррекция)*/
CargoPlace ccp = cargoPlaceService.findConsolidationByNestedStatus(status);
CargoPlaceStatus ccpStatus = cargoPlaceService.findStatusByUuid(ccp.getStatusUuid());
if (status.getDocumentType() != DocumentType.DECONSOLIDATION || ccpStatus.getDocumentType() != DocumentType.DECONSOLIDATION) {
//ошибочное состояние, ПГМ и КГМ должны указывать на документ Расконсолидации
LOGGER.warn("Unexpected status of cargo place :{} and its consolidation :{}", status, ccpStatus);
result.addError(Messages.CORRECTION_ERROR);
return;
}
//находим Расконсолидацию и проверяем филиал
Document document = documentService.findByUuid(ccpStatus.getDocumentId());
result.addRelatedDocument(document.getType(), document.getNumber());
if (ObjectUtils.equals(document.getCurrentBranch(), currentBranch)) {
//расконсолидация на этом филиале
}
}
@Required
public void setDocumentService(DocumentService documentService) {
this.documentService = documentService;
}
@Required
public void setConsolidationService(ConsolidationService consolidationService) {
this.consolidationService = consolidationService;
}
@Required
public void setShipmentService(ShipmentService shipmentService) {
this.shipmentService = shipmentService;
}
@Required
public void setCargoPlaceService(CargoPlaceService cargoPlaceService) {
this.cargoPlaceService = cargoPlaceService;
......
......@@ -2,8 +2,6 @@ package com.cdek.warehouse.services.correction.impl;
import com.cdek.transport.model.cargoplace.CargoPlace;
import com.cdek.transport.model.cargoplace.CargoPlaceStatus;
import com.cdek.transport.model.document.Consolidation;
import com.cdek.transport.model.document.DocumentRef;
import com.cdek.transport.model.document.correction.CorrectionShipment;
import com.cdek.transport.model.operation.CargoPlaceAdding;
import com.cdek.transport.model.operation.CorrectionAttempt;
......@@ -11,22 +9,17 @@ import com.cdek.warehouse.common.Messages;
import com.cdek.warehouse.services.correction.CorrectionException;
import com.cdek.warehouse.services.correction.CorrectionShipmentResult;
import com.cdek.warehouse.services.correction.RemoteCorrection;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static com.cdek.transport.ek4.WarehouseConstants.SEMICOLON_DELIMITER;
/**
* Коррекция на удаленном филиале
* Коррекция на удаленном филиале для ПГМ в документе Первичный Приход
*/
public class PrimeIncomeRemoteCorrection extends BaseRemoteCorrectionStrategy implements RemoteCorrection {
private static final Logger LOGGER = LoggerFactory.getLogger(PrimeIncomeRemoteCorrection.class);
public class PrimeIncomeRemoteCorrectionStrategy extends BaseRemoteCorrectionStrategy implements RemoteCorrection {
private static final Logger LOGGER = LoggerFactory.getLogger(PrimeIncomeRemoteCorrectionStrategy.class);
@Override
public CorrectionShipmentResult execute(CorrectionAttempt correctionAttempt) throws CorrectionException {
......
......@@ -7,17 +7,14 @@ import com.cdek.transport.model.document.correction.IncomeActionType;
import com.cdek.transport.model.document.correction.VerifyResult;
import com.cdek.warehouse.common.Messages;
import com.cdek.warehouse.services.correction.IncomeVerifyStrategy;
import com.cdek.warehouse.services.document.ReturnUndeliveredService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
/**
* Верификатор для ГМ в документе Возврат недоставленного {@link com.cdek.transport.model.document.ReturnUndelivered}
*/
public class ReturnUndeliveredVerifyStrategy extends BaseVerifyStrategy implements IncomeVerifyStrategy {
private static final Logger LOGGER = LoggerFactory.getLogger(ReturnUndeliveredVerifyStrategy.class);
private ReturnUndeliveredService returnUndeliveredService;
@Override
public VerifyResult execute(CargoPlace cargoPlace, String branchTo) {
......@@ -26,14 +23,14 @@ public class ReturnUndeliveredVerifyStrategy extends BaseVerifyStrategy implemen
fillResultWithCargoPlaceInfo(result, cargoPlace);
fillResultWithStatusInfo(result, status);
if(activeAndNotConsolidated(status)){
if (activeAndNotConsolidated(status)) {
if (cargoPlaceAlreadyInBranch(branchTo, status.getCurrentBranch(), result)) {
//значит ПГМ из этого же филиала, корректировка не нужна.
result.setActionType(IncomeActionType.ACTIVE_ON_BRANCH);
return result;
}
verifyReturnUndelivered(status, result);
}else {
} else {
LOGGER.error("inconsistent status for document :{}. expected active and not consolidated", status);
result.addError(Messages.CORRECTION_ERROR, IncomeActionType.ILLEGAL_STATE);
}
......@@ -51,9 +48,4 @@ public class ReturnUndeliveredVerifyStrategy extends BaseVerifyStrategy implemen
result.setActionType(IncomeActionType.REMOTE_CORRECTION);
}
@Required
public void setReturnUndeliveredService(ReturnUndeliveredService returnUndeliveredService) {
this.returnUndeliveredService = returnUndeliveredService;
}
}
......@@ -70,7 +70,7 @@ public class ShipmentVerifyStrategy extends BaseVerifyStrategy implements Income
result.setBranchFromCode(shipment.getBranchFrom());
//Консолидация была на том же филиале, она закрыта, т.к. в Отправке
if (isAtBranch(consolidation, branchTo)){
if (isAtBranch(consolidation, branchTo)) {
LOGGER.info("Consolidation is already at the branch");
result.setActionType(IncomeActionType.LOCAL_CORRECTION);
return;
......
......@@ -19,9 +19,6 @@
/>
<bean id="incomeVerifier" class="com.cdek.warehouse.services.correction.impl.IncomeVerifierImpl"
p:documentService-ref="documentService"
p:consolidationService-ref="consolidationService"
p:shipmentService-ref="shipmentService"
p:cargoPlaceService-ref="cargoPlaceService"
p:verifyStrategyMap-ref="verifyStrategyMap"
/>
......@@ -67,7 +64,6 @@
/>
<bean id="returnUndeliveredVerifyStrategy" class="com.cdek.warehouse.services.correction.impl.ReturnUndeliveredVerifyStrategy"
parent="baseVerifyStrategy"
p:returnUndeliveredService-ref="returnUndeliveredService"
/>
<!-- Стратегии для Локальной коррекции ПГМ -->
......@@ -97,19 +93,19 @@
<!-- Стратегии для Удаленной коррекции ПГМ -->
<util:map id="remoteCorrectionStrategyMap" key-type="com.cdek.transport.model.document.DocumentType" value-type="com.cdek.warehouse.services.correction.RemoteCorrection">
<entry key="PRIME_INCOME" value-ref="primeIncomeRemoteCorrection"/>
<entry key="CONSOLIDATION" value-ref="consolidationRemoteCorrection"/>
<entry key="SHIPMENT" value-ref="consolidationRemoteCorrection"/>
<entry key="PRIME_INCOME" value-ref="primeIncomeRemoteCorrectionStrategy"/>
<entry key="CONSOLIDATION" value-ref="consolidationRemoteCorrectionStrategy"/>
<entry key="SHIPMENT" value-ref="consolidationRemoteCorrectionStrategy"/>
<entry key="DECONSOLIDATION" value-ref="deconsolidationRemoteCorrectionStrategy"/>
<entry key="DELIVERY" value-ref="deliveryRemoteCorrectionStrategy"/>
<entry key="RETURN_UNDELIVERED" value-ref="primeIncomeRemoteCorrection"/>
<entry key="RETURN_UNDELIVERED" value-ref="primeIncomeRemoteCorrectionStrategy"/>
</util:map>
<bean id="baseRemoteCorrectionStrategy" class="com.cdek.warehouse.services.correction.impl.BaseRemoteCorrectionStrategy" abstract="true"
p:documentService-ref="documentService"
p:consolidationService-ref="consolidationService"
p:documentFillingService-ref="documentFillingService"
p:forceCargoPlaceDeletionService-ref="forceCargoPlaceDeletionService"
p:consolidationService-ref="consolidationService"
p:cargoPlaceService-ref="cargoPlaceService"
p:catalogsService-ref="catalogsService"
p:correctionShipmentService-ref="correctionShipmentService"
......@@ -117,24 +113,19 @@
p:systemUserCode="${system.user.code}"
/>
<bean id="primeIncomeRemoteCorrection" class="com.cdek.warehouse.services.correction.impl.PrimeIncomeRemoteCorrection"
<bean id="primeIncomeRemoteCorrectionStrategy" class="com.cdek.warehouse.services.correction.impl.PrimeIncomeRemoteCorrectionStrategy"
parent="baseRemoteCorrectionStrategy"
/>
<bean id="consolidationRemoteCorrection" class="com.cdek.warehouse.services.correction.impl.ConsolidationRemoteCorrection"
<bean id="consolidationRemoteCorrectionStrategy" class="com.cdek.warehouse.services.correction.impl.ConsolidationRemoteCorrectionStrategy"
parent="baseRemoteCorrectionStrategy"
/>
<bean id="deliveryRemoteCorrectionStrategy" class="com.cdek.warehouse.services.correction.impl.DeliveryRemoteCorrectionStrategy"
parent="baseRemoteCorrectionStrategy"
/>
<bean id="deconsolidationRemoteCorrectionStrategy" class="com.cdek.warehouse.services.correction.impl.DeconsolidationRemoteCorrectionStrategy"
parent="baseRemoteCorrectionStrategy"
p:deconsolidationService-ref="deconsolidationService"
/>
</beans>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment