Bulk operation:
- Fixed empty kilometer rates and container rates
This commit is contained in:
parent
ef76bf382f
commit
f68a6b30a5
3 changed files with 37 additions and 34 deletions
|
|
@ -69,38 +69,38 @@ public class BulkOperationRepository {
|
|||
// First, update sys_error records to set bulk_operation_id to NULL
|
||||
// for bulk operations that will be deleted (all but the 10 newest for the current user)
|
||||
String updateErrorsSql = """
|
||||
UPDATE sys_error
|
||||
SET bulk_operation_id = NULL
|
||||
WHERE bulk_operation_id IN (
|
||||
SELECT id FROM (
|
||||
SELECT id
|
||||
FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 18446744073709551615 OFFSET 10
|
||||
) AS old_operations
|
||||
)
|
||||
""";
|
||||
UPDATE sys_error
|
||||
SET bulk_operation_id = NULL
|
||||
WHERE bulk_operation_id IN (
|
||||
SELECT id FROM (
|
||||
SELECT id
|
||||
FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 18446744073709551615 OFFSET 10
|
||||
) AS old_operations
|
||||
)
|
||||
""";
|
||||
|
||||
jdbcTemplate.update(updateErrorsSql, userId);
|
||||
|
||||
// Then delete the old bulk_operation entries (keeping only the 10 newest for the current user)
|
||||
String deleteBulkSql = """
|
||||
DELETE FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
AND id NOT IN (
|
||||
SELECT id FROM (
|
||||
SELECT id
|
||||
FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10
|
||||
) AS newest_operations
|
||||
)
|
||||
""";
|
||||
DELETE FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
AND id NOT IN (
|
||||
SELECT id FROM (
|
||||
SELECT id
|
||||
FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
AND state NOT IN ('SCHEDULED', 'PROCESSING')
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10
|
||||
) AS newest_operations
|
||||
)
|
||||
""";
|
||||
|
||||
jdbcTemplate.update(deleteBulkSql, userId, userId);
|
||||
}
|
||||
|
|
@ -119,10 +119,10 @@ public class BulkOperationRepository {
|
|||
@Transactional
|
||||
public List<BulkOperation> listByUserId(Integer userId) {
|
||||
String sql = """
|
||||
SELECT id, user_id, bulk_file_type, bulk_processing_type, state, created_at
|
||||
SELECT id, user_id, bulk_file_type, bulk_processing_type, state, created_at, validity_period_id
|
||||
FROM bulk_operation
|
||||
WHERE user_id = ?
|
||||
|
||||
|
||||
ORDER BY created_at DESC LIMIT 10
|
||||
""";
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ public class BulkOperationRepository {
|
|||
@Transactional
|
||||
public Optional<BulkOperation> getOperationById(Integer id) {
|
||||
String sql = """
|
||||
SELECT id, user_id, bulk_file_type, bulk_processing_type, state, file, created_at
|
||||
SELECT id, user_id, bulk_file_type, bulk_processing_type, state, file, created_at, validity_period_id
|
||||
FROM bulk_operation
|
||||
WHERE id = ?
|
||||
""";
|
||||
|
|
@ -180,6 +180,12 @@ public class BulkOperationRepository {
|
|||
operation.setProcessingType(BulkProcessingType.valueOf(rs.getString("bulk_processing_type")));
|
||||
operation.setFileType(BulkFileType.valueOf(rs.getString("bulk_file_type")));
|
||||
operation.setProcessState(BulkOperationState.valueOf(rs.getString("state")));
|
||||
|
||||
|
||||
operation.setValidityPeriodId(rs.getInt("validity_period_id"));
|
||||
if (rs.wasNull())
|
||||
operation.setValidityPeriodId(null);
|
||||
|
||||
if (!skipFile)
|
||||
operation.setFile(rs.getBytes("file"));
|
||||
operation.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime());
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class BulkImportService {
|
|||
break;
|
||||
case COUNTRY_MATRIX:
|
||||
var matrixRates = matrixRateExcelMapper.extractSheet(sheet);
|
||||
matrixRates.forEach(System.out::println);
|
||||
break;
|
||||
case MATERIAL:
|
||||
var materials = materialExcelMapper.extractSheet(sheet);
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ public class MaterialBulkImportService {
|
|||
this.materialRepository = materialRepository;
|
||||
}
|
||||
|
||||
private static String normalizePartNumber(String partNumber) {
|
||||
if (partNumber.length() > 12) throw new IllegalArgumentException("Part number must be less than 12 characters");
|
||||
return "000000000000".concat(partNumber).substring(partNumber.length());
|
||||
}
|
||||
|
||||
public void processMaterialInstructions(BulkInstruction<Material> instr) {
|
||||
BulkInstructionType instrType = instr.getType();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue