优化
This commit is contained in:
@@ -34,6 +34,7 @@ public final class ColoadGroupModels {
|
||||
long tenantId,
|
||||
long orderId,
|
||||
long inboundId,
|
||||
String inboundCode,
|
||||
int fullPackageCount
|
||||
) {
|
||||
}
|
||||
|
||||
+14
-9
@@ -66,9 +66,15 @@ public interface ColoadGroupMapper {
|
||||
+ "FROM fl_coload_group WHERE id=#{groupId} FOR UPDATE")
|
||||
GroupRow lockGroup(@Param("groupId") long groupId);
|
||||
|
||||
@Select("SELECT tenant_id tenantId,order_id orderId,inbound_id inboundId,"
|
||||
+ "full_package_count fullPackageCount FROM fl_coload_group_member "
|
||||
+ "WHERE group_id=#{groupId} ORDER BY order_id,inbound_id")
|
||||
@Select("""
|
||||
SELECT member.tenant_id tenantId,member.order_id orderId,member.inbound_id inboundId,
|
||||
inbound.inbound_code inboundCode,member.full_package_count fullPackageCount
|
||||
FROM fl_coload_group_member member
|
||||
LEFT JOIN fl_inbound_order inbound
|
||||
ON inbound.tenant_id=member.tenant_id AND inbound.id=member.inbound_id AND inbound.deleted=0
|
||||
WHERE member.group_id=#{groupId}
|
||||
ORDER BY member.order_id,member.inbound_id
|
||||
""")
|
||||
List<MemberRow> members(@Param("groupId") long groupId);
|
||||
|
||||
@Select("""
|
||||
@@ -98,13 +104,12 @@ public interface ColoadGroupMapper {
|
||||
List<InboundGroupLookupRow> groupsByInboundCode(@Param("inboundCode") String inboundCode);
|
||||
|
||||
@Select("""
|
||||
SELECT DISTINCT inbound.inbound_code inboundCode
|
||||
SELECT member.id memberId,member.inbound_id inboundId,inbound.inbound_code inboundCode
|
||||
FROM fl_coload_group_member member
|
||||
JOIN fl_inbound_order inbound
|
||||
ON inbound.tenant_id=member.tenant_id AND inbound.id=member.inbound_id
|
||||
WHERE member.group_id=#{groupId} AND inbound.deleted=0
|
||||
AND inbound.inbound_code IS NOT NULL AND TRIM(inbound.inbound_code)<>''
|
||||
ORDER BY inbound.inbound_code
|
||||
LEFT JOIN fl_inbound_order inbound
|
||||
ON inbound.tenant_id=member.tenant_id AND inbound.id=member.inbound_id AND inbound.deleted=0
|
||||
WHERE member.group_id=#{groupId}
|
||||
ORDER BY member.id
|
||||
""")
|
||||
List<MemberCodeRow> effectiveMemberCodes(@Param("groupId") long groupId);
|
||||
|
||||
|
||||
+3
@@ -44,6 +44,7 @@ public final class ColoadPersistenceRows {
|
||||
private Long tenantId;
|
||||
private Long orderId;
|
||||
private Long inboundId;
|
||||
private String inboundCode;
|
||||
private Integer fullPackageCount;
|
||||
}
|
||||
|
||||
@@ -57,6 +58,8 @@ public final class ColoadPersistenceRows {
|
||||
@Getter
|
||||
@Setter
|
||||
public static class MemberCodeRow {
|
||||
private Long memberId;
|
||||
private Long inboundId;
|
||||
private String inboundCode;
|
||||
}
|
||||
|
||||
|
||||
+24
-10
@@ -104,14 +104,17 @@ public class ColoadGroupService implements ColoadGroupAssignmentPort {
|
||||
if (distinctGroups > 1) throw conflict("入仓码关联多个有效同柜不可拆组");
|
||||
long groupId = groups.get(0).getGroupId();
|
||||
String status = groups.get(0).getGroupStatus();
|
||||
List<BusinessMember> members = mapper.effectiveMemberCodes(groupId).stream()
|
||||
.map(row -> trim(row.getInboundCode()))
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.sorted()
|
||||
.map(BusinessMember::new)
|
||||
.toList();
|
||||
if (members.isEmpty()) throw conflict("同柜不可拆组不存在有效入仓片段");
|
||||
var memberRows = mapper.effectiveMemberCodes(groupId);
|
||||
if (memberRows.isEmpty()) throw conflict("同柜不可拆组不存在有效入仓片段");
|
||||
if (memberRows.stream().anyMatch(row -> row.getMemberId() == null || row.getInboundId() == null
|
||||
|| trim(row.getInboundCode()) == null)) {
|
||||
throw conflict("同柜不可拆组存在缺失或无效的入仓片段业务号");
|
||||
}
|
||||
List<String> inboundCodes = memberRows.stream().map(row -> trim(row.getInboundCode())).toList();
|
||||
if (inboundCodes.stream().distinct().count() != inboundCodes.size()) {
|
||||
throw conflict("同柜不可拆组存在重复入仓片段业务号");
|
||||
}
|
||||
List<BusinessMember> members = inboundCodes.stream().sorted().map(BusinessMember::new).toList();
|
||||
return new BusinessSummary(status, members.size(), members);
|
||||
}
|
||||
|
||||
@@ -271,9 +274,20 @@ public class ColoadGroupService implements ColoadGroupAssignmentPort {
|
||||
}
|
||||
|
||||
private GroupSnapshot snapshot(GroupRow row) {
|
||||
List<Member> members = mapper.members(row.getId()).stream()
|
||||
var memberRows = mapper.members(row.getId());
|
||||
if (memberRows.isEmpty() || memberRows.stream().anyMatch(value -> value.getTenantId() == null
|
||||
|| value.getOrderId() == null || value.getInboundId() == null
|
||||
|| trim(value.getInboundCode()) == null || value.getFullPackageCount() == null
|
||||
|| value.getFullPackageCount() <= 0)) {
|
||||
throw conflict("同柜不可拆组存在缺失或无效的冻结成员业务事实");
|
||||
}
|
||||
List<String> codes = memberRows.stream().map(value -> trim(value.getInboundCode())).toList();
|
||||
if (codes.stream().distinct().count() != codes.size()) {
|
||||
throw conflict("同柜不可拆组存在重复入仓片段业务号");
|
||||
}
|
||||
List<Member> members = memberRows.stream()
|
||||
.map(value -> new Member(value.getTenantId(), value.getOrderId(), value.getInboundId(),
|
||||
value.getFullPackageCount()))
|
||||
trim(value.getInboundCode()), value.getFullPackageCount()))
|
||||
.toList();
|
||||
return new GroupSnapshot(row.getId(), row.getGroupNo(), row.getGroupStatus(), row.getWarehouseId(),
|
||||
row.getChannelCode(), row.getLockedPlanId(), row.getVersion(), members,
|
||||
|
||||
Reference in New Issue
Block a user