Commit e89d53f0 authored by Xenia Ulyanova's avatar Xenia Ulyanova
Browse files

review fixes

parent a05308a3
Showing with 56 additions and 39 deletions
+56 -39
......@@ -5,10 +5,13 @@ DROP TABLE IF EXISTS document_return_undelivered;
DROP TABLE IF EXISTS operation_return_undelivered_create_or_update;
-- обновления модели Операции
ALTER TABLE operation_force_cargo_place_deletion ADD COLUMN document_uuid UUID;
ALTER TABLE operation_force_cargo_place_deletion
ADD COLUMN document_uuid UUID;
BEGIN;
ALTER TABLE operation_force_cargo_place_deletion DROP CONSTRAINT check_document;
ALTER TABLE operation_force_cargo_place_deletion ADD CONSTRAINT check_document CHECK (document_type = 'CONSOLIDATION' OR document_type = 'DELIVERY');
ALTER TABLE operation_force_cargo_place_deletion
DROP CONSTRAINT check_document;
ALTER TABLE operation_force_cargo_place_deletion
ADD CONSTRAINT check_document CHECK (document_type = 'CONSOLIDATION' OR document_type = 'DELIVERY');
COMMIT;
CREATE TABLE document_return_undelivered (
......@@ -25,31 +28,43 @@ CREATE TABLE document_return_undelivered (
FOREIGN KEY (uuid) REFERENCES document (uuid)
);
CREATE INDEX return_sked_index ON document_return_undelivered (sked_number);
CREATE INDEX return_ext_id_index ON document_return_undelivered (external_id);
CREATE INDEX return_ext_date_index ON document_return_undelivered (external_date_updated);
CREATE INDEX return_emp_out_index ON document_return_undelivered (employee_passed);
CREATE INDEX return_emp_in_index ON document_return_undelivered (employee_accepted);
CREATE TABLE operation_return_undelivered_create_or_update (
uuid UUID UNIQUE,
type VARCHAR(50),
status VARCHAR(50),
date DATE NOT NULL,
description JSONB,
uuid UUID UNIQUE,
type VARCHAR(50),
status VARCHAR(50),
date DATE NOT NULL,
description JSONB,
document_uuid UUID,
document_type VARCHAR(50),
branch VARCHAR(50),
document_uuid UUID,
document_type VARCHAR(50),
branch VARCHAR(50),
user_code VARCHAR(50),
error_code VARCHAR(50),
user_code VARCHAR(50),
error_code VARCHAR(50),
employee_passed VARCHAR(50),
employee_passed VARCHAR(50),
employee_accepted VARCHAR(50),
date_created TIMESTAMP NOT NULL DEFAULT NOW(),
date_updated TIMESTAMP NOT NULL DEFAULT NOW(),
date_created TIMESTAMP NOT NULL DEFAULT NOW(),
date_updated TIMESTAMP NOT NULL DEFAULT NOW(),
PRIMARY KEY (uuid),
CONSTRAINT check_types CHECK (type = 'CREATION' OR type = 'UPDATE')
);
CREATE INDEX op_return_created_index ON operation_return_undelivered_create_or_update (date_created);
CREATE INDEX op_return_status_index ON operation_return_undelivered_create_or_update (status);
CREATE INDEX op_return_document_index ON operation_return_undelivered_create_or_update (document_uuid);
CREATE INDEX op_return_branch_index ON operation_return_undelivered_create_or_update (branch);
CREATE INDEX op_return_user_index ON operation_return_undelivered_create_or_update (user_code);
CREATE INDEX op_return_error_index ON operation_return_undelivered_create_or_update (error_code);
CREATE TABLE document_delivery (
......@@ -58,33 +73,43 @@ CREATE TABLE document_delivery (
external_date_updated TIMESTAMP,
external_id BIGINT,
sked_number VARCHAR(20),
employee_passed VARCHAR(20),
employee_accepted VARCHAR(20),
employee_passed VARCHAR(20),
employee_accepted VARCHAR(20),
PRIMARY KEY (uuid),
FOREIGN KEY (uuid) REFERENCES document (uuid)
);
CREATE INDEX delivery_sked_index ON document_delivery (sked_number);
CREATE INDEX delivery_ext_id_index ON document_delivery (external_id);
CREATE INDEX delivery_ext_date_index ON document_delivery (external_date_updated);
CREATE INDEX delivery_emp_out_index ON document_delivery (employee_passed);
CREATE INDEX delivery_emp_in_index ON document_delivery (employee_accepted);
CREATE TABLE operation_delivery_create_or_update (
uuid UUID UNIQUE,
type VARCHAR(50),
document_type VARCHAR(50),
status VARCHAR(50),
user_code VARCHAR(20),
error_code VARCHAR(50),
description JSONB,
date_created TIMESTAMP NOT NULL DEFAULT NOW(),
date_updated TIMESTAMP NOT NULL DEFAULT NOW(),
uuid UUID UNIQUE,
type VARCHAR(50),
document_type VARCHAR(50),
status VARCHAR(50),
user_code VARCHAR(20),
error_code VARCHAR(50),
description JSONB,
date_created TIMESTAMP NOT NULL DEFAULT NOW(),
date_updated TIMESTAMP NOT NULL DEFAULT NOW(),
document_uuid UUID,
employee_passed VARCHAR(20),
employee_accepted VARCHAR(20),
date DATE NOT NULL,
date DATE NOT NULL,
branch VARCHAR(50),
PRIMARY KEY (uuid),
CONSTRAINT check_types CHECK (type = 'CREATION' OR type = 'UPDATE')
);
-- TODO refactor: indexes?
\ No newline at end of file
CREATE INDEX op_delivery_created_index ON operation_delivery_create_or_update (date_created);
CREATE INDEX op_delivery_status_index ON operation_delivery_create_or_update (status);
CREATE INDEX op_delivery_document_index ON operation_delivery_create_or_update (document_uuid);
CREATE INDEX op_delivery_branch_index ON operation_delivery_create_or_update (branch);
CREATE INDEX op_delivery_user_index ON operation_delivery_create_or_update (user_code);
CREATE INDEX op_delivery_error_index ON operation_delivery_create_or_update (error_code);
\ No newline at end of file
......@@ -42,7 +42,7 @@
<delete id="delete" parameterType="Deconsolidation">
<include refid="com.cdek.warehouse.dao.mapper.document.DocumentMapper.deleteSql"/>
<!-- TODO refactor: может не удалять-->
<!-- для каждого КГМ разрешен только один документ расконсолидации -->
UPDATE document_deconsolidation
SET cargo_place_uuid = NULL
WHERE uuid = #{uuid};
......
......@@ -112,7 +112,6 @@ public class CorrectionAttemptServiceImpl extends DocumentOperationService imple
/**
* Операция добавления должна происходить в ту же дату, что и дата документа Приход-Коррекция
*/
//todo refactor, create date validator
protected void checkDate(CorrectionAttempt operation) {
Assert.notNull(operation.getDateUpdated());
CorrectionIncome correctionIncome = correctionIncomeService.findByUuid(operation.getDocumentUuid());
......@@ -123,13 +122,6 @@ public class CorrectionAttemptServiceImpl extends DocumentOperationService imple
operation.makeFailed(e.getKey());
operationDAO.save(operation);
}
//TODO refactor: удалить мусор
// LocalDate operationDate = operation.getDateCreated().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// LocalDate documentDate = correctionIncome.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// if (!operationDate.equals(documentDate)) {
//
// operation.makeFailed(OperationError.DOCUMENT_AND_OPERATION_DATE_MISMATCH.getCode());
// }
}
/**
......
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