diff --git a/firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformSmartLoadingController.java b/firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformSmartLoadingController.java index d6c02bf72..d018e4cd8 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformSmartLoadingController.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformSmartLoadingController.java @@ -22,6 +22,8 @@ public class PlatformSmartLoadingController { public ApiResponse recommend(@AuthenticationPrincipal AuthenticatedUser u,@PathVariable @Positive long planId,@Valid @RequestBody RecommendRequest r){FirstlegScopeGuard.platform(u);return ApiResponse.success(service.recommend(planId,r,u.userId(),u.username()));} @PatchMapping("/plans/{planId}/items/{itemId}") @PreAuthorize("hasAuthority('platform:firstleg:smart-loading:assign')") public ApiResponse adjust(@AuthenticationPrincipal AuthenticatedUser u,@PathVariable @Positive long planId,@PathVariable @Positive long itemId,@Valid @RequestBody AdjustRequest r){FirstlegScopeGuard.platform(u);return ApiResponse.success(service.adjust(planId,itemId,r,u.userId(),u.username()));} + @PatchMapping("/plans/{planId}/items/{itemId}/warehouse-remark") @PreAuthorize("hasAuthority('platform:firstleg:smart-loading:assign')") + public ApiResponse warehouseRemark(@AuthenticationPrincipal AuthenticatedUser u,@PathVariable @Positive long planId,@PathVariable @Positive long itemId,@Valid @RequestBody WarehouseRemarkRequest r){FirstlegScopeGuard.platform(u);return ApiResponse.success(service.updateWarehouseRemark(planId,itemId,r,u.userId(),u.username()));} @DeleteMapping("/plans/{planId}/items/{itemId}") @PreAuthorize("hasAuthority('platform:firstleg:smart-loading:delete')") public ApiResponse delete(@AuthenticationPrincipal AuthenticatedUser u,@PathVariable @Positive long planId,@PathVariable @Positive long itemId,@Valid @RequestBody DeleteRequest r){FirstlegScopeGuard.platform(u);return ApiResponse.success(service.delete(planId,itemId,r,u.userId(),u.username()));} @PostMapping("/plans/{planId}/push-preload") @PreAuthorize("hasAuthority('platform:firstleg:smart-loading:push')") diff --git a/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java b/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java index c42322654..dba00e1f0 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java @@ -25,6 +25,9 @@ public final class SmartLoadingDtos { private SmartLoadingDtos(){} @NotNull @Min(0) Integer expectedItemVersion,@NotBlank @Size(max=128) String operationId) {} public record DeleteRequest(@NotNull @Min(0) Integer expectedPlanVersion, @NotNull @Min(0) Integer expectedItemVersion,@NotBlank @Size(max=128) String operationId) {} + public record WarehouseRemarkRequest(@Size(max=1000) String warehouseRemark, + @NotNull @Min(0) Integer expectedPlanVersion, @NotNull @Min(0) Integer expectedItemVersion, + @NotBlank @Size(max=128) String operationId) {} public record PushRequest(@NotNull @Min(0) Integer expectedVersion) {} public record Plan(Long id,String planNo,String status,Long bookingId,String containerNo,String voyageNo, Integer version,Boolean canAssign,Boolean canEdit,String blockedReason,String finalCompletionStatus, diff --git a/firstleg/src/main/java/com/baiyue/firstleg/mapper/LoadingPlanItemMapper.java b/firstleg/src/main/java/com/baiyue/firstleg/mapper/LoadingPlanItemMapper.java index 75b4eb3b1..7bc4f80e9 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/mapper/LoadingPlanItemMapper.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/mapper/LoadingPlanItemMapper.java @@ -9,4 +9,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baiyue.firstl AND version=#{expectedVersion} """) int removeEditing(@Param("planId") long planId,@Param("itemId") long itemId,@Param("expectedVersion") int expectedVersion,@Param("operatorId") long operatorId,@Param("operatorName") String operatorName); + @Update(""" + UPDATE fl_loading_plan_item i JOIN fl_loading_plan p ON p.id=i.loading_plan_id + SET i.warehouse_remark=#{remark}, i.updated_by=#{operatorId}, i.updated_by_name=#{operatorName}, + i.updated_at=CURRENT_TIMESTAMP(3), i.version=i.version+1, + p.version=p.version+1, p.updated_by=#{operatorId}, p.updated_by_name=#{operatorName}, + p.updated_at=CURRENT_TIMESTAMP(3) + WHERE i.id=#{itemId} AND i.loading_plan_id=#{planId} AND i.deleted=0 + AND i.version=#{expectedItemVersion} AND p.version=#{expectedPlanVersion} + AND p.plan_status IN ('EDITING','LOADING') + """) + int updateWarehouseRemark(@Param("planId") long planId, @Param("itemId") long itemId, + @Param("expectedPlanVersion") int expectedPlanVersion, + @Param("expectedItemVersion") int expectedItemVersion, + @Param("remark") String remark, @Param("operatorId") long operatorId, + @Param("operatorName") String operatorName); } diff --git a/firstleg/src/main/java/com/baiyue/firstleg/repository/SmartLoadingRepository.java b/firstleg/src/main/java/com/baiyue/firstleg/repository/SmartLoadingRepository.java index 448d2ea9c..095a678a6 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/repository/SmartLoadingRepository.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/repository/SmartLoadingRepository.java @@ -69,6 +69,11 @@ public class SmartLoadingRepository { public int remove(long planId, long itemId, int version, long operatorId, String operatorName) { return items.removeEditing(planId, itemId, version, operatorId, operatorName); } + public int updateWarehouseRemark(long planId, long itemId, int expectedPlanVersion, int expectedItemVersion, + String remark, long operatorId, String operatorName) { + return items.updateWarehouseRemark(planId, itemId, expectedPlanVersion, expectedItemVersion, + remark, operatorId, operatorName); + } public int push(long planId, String key, int version, long operatorId, String operatorName) { return plans.pushPreload(planId, key, version, operatorId, operatorName); }