1、调整导入运单

2、调整对账
This commit is contained in:
2026-09-09 15:39:21 +08:00
parent 63af35a333
commit 049a46227d
11 changed files with 236 additions and 16 deletions
@@ -38,6 +38,10 @@ public class FormalSettlementDetail extends TenantEntity {
private String vehicleNo; private String vehicleNo;
private String departureAddress; private String departureAddress;
private String arrivalAddress; private String arrivalAddress;
private String departureContact;
private String departurePhone;
private String arrivalContact;
private String arrivalPhone;
private LocalDateTime actualDepartureTime; private LocalDateTime actualDepartureTime;
private LocalDateTime actualCompletionTime; private LocalDateTime actualCompletionTime;
private String transportType; private String transportType;
@@ -57,9 +57,21 @@ public class PreSettlementDetail extends TenantEntity {
@Schema(description = "发货地址") @Schema(description = "发货地址")
private String departureAddress; private String departureAddress;
@Schema(description = "货地址") @Schema(description = "货地址")
private String arrivalAddress; private String arrivalAddress;
@Schema(description = "发货联系人")
private String departureContact;
@Schema(description = "发货联系方式")
private String departurePhone;
@Schema(description = "收货联系人")
private String arrivalContact;
@Schema(description = "收货联系方式")
private String arrivalPhone;
@Schema(description = "实际发货时间") @Schema(description = "实际发货时间")
private LocalDateTime actualDepartureTime; private LocalDateTime actualDepartureTime;
@@ -82,6 +82,24 @@ public class ReceivablePayableDetail extends TenantEntity {
@Schema(description = "来源") @Schema(description = "来源")
private String sourceType; private String sourceType;
@Schema(description = "发货地址")
private String departureAddress;
@Schema(description = "收货地址")
private String arrivalAddress;
@Schema(description = "发货联系人")
private String departureContact;
@Schema(description = "发货联系方式")
private String departurePhone;
@Schema(description = "收货联系人")
private String arrivalContact;
@Schema(description = "收货联系方式")
private String arrivalPhone;
@Schema(description = "预结算单号") @Schema(description = "预结算单号")
private String preSettlementNo; private String preSettlementNo;
@@ -114,8 +114,9 @@ public class ProcessConfigController extends BladeController {
.eq(VoucherImage::getMatched, 1) .eq(VoucherImage::getMatched, 1)
.eq(VoucherImage::getIsDeleted, 0) .eq(VoucherImage::getIsDeleted, 0)
.orderByDesc(VoucherImage::getCreateTime)); .orderByDesc(VoucherImage::getCreateTime));
Map<Long, VoucherManage> voucherMap = voucherManageMapper.selectBatchIds(imageRecords.stream() List<Long> voucherIds = imageRecords.stream()
.map(VoucherImage::getVoucherId).filter(java.util.Objects::nonNull).distinct().toList()).stream() .map(VoucherImage::getVoucherId).filter(java.util.Objects::nonNull).distinct().toList();
Map<Long, VoucherManage> voucherMap = voucherIds.isEmpty() ? Map.of() : voucherManageMapper.selectBatchIds(voucherIds).stream()
.collect(java.util.stream.Collectors.toMap(VoucherManage::getId, item -> item, (left, right) -> left)); .collect(java.util.stream.Collectors.toMap(VoucherManage::getId, item -> item, (left, right) -> left));
List<Map<String, Object>> images = imageRecords.stream() List<Map<String, Object>> images = imageRecords.stream()
// 承运商上传的凭证只允许审核通过后在运单详情展示,内部上传保持原有展示规则。 // 承运商上传的凭证只允许审核通过后在运单详情展示,内部上传保持原有展示规则。
@@ -211,8 +211,10 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
List<FormalSettlementSource> sources = sourceMapper.selectList(Wrappers.<FormalSettlementSource>lambdaQuery() List<FormalSettlementSource> sources = sourceMapper.selectList(Wrappers.<FormalSettlementSource>lambdaQuery()
.eq(FormalSettlementSource::getFormalSettlementId, id).orderByAsc(FormalSettlementSource::getCreateTime)); .eq(FormalSettlementSource::getFormalSettlementId, id).orderByAsc(FormalSettlementSource::getCreateTime));
vo.setSources(sources); vo.setSources(sources);
vo.setDetails(detailMapper.selectList(Wrappers.<FormalSettlementDetail>lambdaQuery() List<FormalSettlementDetail> details = detailMapper.selectList(Wrappers.<FormalSettlementDetail>lambdaQuery()
.eq(FormalSettlementDetail::getFormalSettlementId, id).orderByAsc(FormalSettlementDetail::getLineNo))); .eq(FormalSettlementDetail::getFormalSettlementId, id).orderByAsc(FormalSettlementDetail::getLineNo));
fillDetailWaybillAddresses(details);
vo.setDetails(details);
vo.setSummaryFees(listSummaryFees(id)); vo.setSummaryFees(listSummaryFees(id));
vo.setPayments(paymentMapper.selectList(Wrappers.<FormalSettlementPayment>lambdaQuery() vo.setPayments(paymentMapper.selectList(Wrappers.<FormalSettlementPayment>lambdaQuery()
.eq(FormalSettlementPayment::getFormalSettlementId, id).orderByDesc(FormalSettlementPayment::getCreateTime))); .eq(FormalSettlementPayment::getFormalSettlementId, id).orderByDesc(FormalSettlementPayment::getCreateTime)));
@@ -246,6 +248,37 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
return vo; return vo;
} }
/**
* 为历史正式结算明细补充运单收发货信息,保留明细中已有的快照值。
*/
private void fillDetailWaybillAddresses(List<FormalSettlementDetail> details) {
if (details == null || details.isEmpty()) return;
List<Long> waybillIds = details.stream()
.map(FormalSettlementDetail::getWaybillId)
.filter(Objects::nonNull)
.distinct()
.toList();
if (waybillIds.isEmpty()) return;
Map<Long, Waybill> waybillMap = waybillService.listByIds(waybillIds).stream()
.collect(Collectors.toMap(Waybill::getId, Function.identity(), (left, right) -> left));
for (FormalSettlementDetail detail : details) {
Waybill waybill = waybillMap.get(detail.getWaybillId());
if (waybill == null) continue;
if (Func.isEmpty(detail.getDepartureAddress())) {
detail.setDepartureAddress(Func.isNotEmpty(waybill.getDepartureAddress())
? waybill.getDepartureAddress() : waybill.getDepartureName());
}
if (Func.isEmpty(detail.getArrivalAddress())) {
detail.setArrivalAddress(Func.isNotEmpty(waybill.getArrivalAddress())
? waybill.getArrivalAddress() : waybill.getArrivalName());
}
if (Func.isEmpty(detail.getDepartureContact())) detail.setDepartureContact(waybill.getDepartureContact());
if (Func.isEmpty(detail.getDeparturePhone())) detail.setDeparturePhone(waybill.getDeparturePhone());
if (Func.isEmpty(detail.getArrivalContact())) detail.setArrivalContact(waybill.getArrivalContact());
if (Func.isEmpty(detail.getArrivalPhone())) detail.setArrivalPhone(waybill.getArrivalPhone());
}
}
private List<FormalSettlementInvoice> listInvoices(FormalSettlement settlement) { private List<FormalSettlementInvoice> listInvoices(FormalSettlement settlement) {
List<FormalSettlementInvoice> settlementInvoices = invoiceMapper.selectList( List<FormalSettlementInvoice> settlementInvoices = invoiceMapper.selectList(
Wrappers.<FormalSettlementInvoice>lambdaQuery() Wrappers.<FormalSettlementInvoice>lambdaQuery()
@@ -1042,7 +1075,10 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
FormalSettlementDetail detail = new FormalSettlementDetail(); FormalSettlementDetail detail = new FormalSettlementDetail();
detail.setFormalSettlementId(settlement.getId()); detail.setSourceDetailId(source.getId()); detail.setLineNo(lineNo++); detail.setFormalSettlementId(settlement.getId()); detail.setSourceDetailId(source.getId()); detail.setLineNo(lineNo++);
detail.setDocumentNo(source.getDocumentNo()); detail.setWaybillId(source.getWaybillId()); detail.setWaybillNo(source.getWaybillNo()); detail.setDocumentNo(source.getDocumentNo()); detail.setWaybillId(source.getWaybillId()); detail.setWaybillNo(source.getWaybillNo());
detail.setVehicleNo(source.getVehicleNo()); detail.setTransportType(source.getTransportType()); detail.setCargoName(source.getCargoName()); detail.setVehicleNo(source.getVehicleNo()); detail.setDepartureAddress(source.getDepartureAddress()); detail.setArrivalAddress(source.getArrivalAddress());
detail.setDepartureContact(source.getDepartureContact()); detail.setDeparturePhone(source.getDeparturePhone());
detail.setArrivalContact(source.getArrivalContact()); detail.setArrivalPhone(source.getArrivalPhone());
detail.setTransportType(source.getTransportType()); detail.setCargoName(source.getCargoName());
detail.setCargoType(source.getCargoType()); detail.setTransportQuantity(money(source.getTransportQuantity())); detail.setQuantityUnit(source.getQuantityUnit()); detail.setCargoType(source.getCargoType()); detail.setTransportQuantity(money(source.getTransportQuantity())); detail.setQuantityUnit(source.getQuantityUnit());
detail.setMileage(source.getMileage()); detail.setBatchNo(source.getBatchNo()); detail.setUnitPrice(source.getUnitPrice()); detail.setMileage(source.getMileage()); detail.setBatchNo(source.getBatchNo()); detail.setUnitPrice(source.getUnitPrice());
detail.setFreightAmount(money(source.getFreightAmount())); detail.setFeeItemsJson(source.getFeeItemsJson()); detail.setFreightAmount(money(source.getFreightAmount())); detail.setFeeItemsJson(source.getFeeItemsJson());
@@ -1050,8 +1086,12 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
detail.setSettlementAmountTax(money(source.getTotalAmount())); detail.setCurrency(Func.isEmpty(source.getCurrency()) ? "RMB" : source.getCurrency()); detail.setSettlementAmountTax(money(source.getTotalAmount())); detail.setCurrency(Func.isEmpty(source.getCurrency()) ? "RMB" : source.getCurrency());
Waybill waybill = source.getWaybillId() == null ? null : waybillService.getById(source.getWaybillId()); Waybill waybill = source.getWaybillId() == null ? null : waybillService.getById(source.getWaybillId());
if (waybill != null) { if (waybill != null) {
detail.setDepartureAddress(Func.isNotEmpty(waybill.getDepartureAddress()) ? waybill.getDepartureAddress() : waybill.getDepartureName()); if (Func.isEmpty(detail.getDepartureAddress())) detail.setDepartureAddress(Func.isNotEmpty(waybill.getDepartureAddress()) ? waybill.getDepartureAddress() : waybill.getDepartureName());
detail.setArrivalAddress(Func.isNotEmpty(waybill.getArrivalAddress()) ? waybill.getArrivalAddress() : waybill.getArrivalName()); if (Func.isEmpty(detail.getArrivalAddress())) detail.setArrivalAddress(Func.isNotEmpty(waybill.getArrivalAddress()) ? waybill.getArrivalAddress() : waybill.getArrivalName());
if (Func.isEmpty(detail.getDepartureContact())) detail.setDepartureContact(waybill.getDepartureContact());
if (Func.isEmpty(detail.getDeparturePhone())) detail.setDeparturePhone(waybill.getDeparturePhone());
if (Func.isEmpty(detail.getArrivalContact())) detail.setArrivalContact(waybill.getArrivalContact());
if (Func.isEmpty(detail.getArrivalPhone())) detail.setArrivalPhone(waybill.getArrivalPhone());
detail.setActualDepartureTime(waybill.getStartDate() == null ? null : waybill.getStartDate().atStartOfDay()); detail.setActualDepartureTime(waybill.getStartDate() == null ? null : waybill.getStartDate().atStartOfDay());
detail.setActualCompletionTime(waybill.getEndDate() == null ? null : waybill.getEndDate().atStartOfDay()); detail.setActualCompletionTime(waybill.getEndDate() == null ? null : waybill.getEndDate().atStartOfDay());
} }
@@ -711,10 +711,18 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
result.put("formalSettlementNo", source.getFormalSettlementNo()); result.put("formalSettlementNo", source.getFormalSettlementNo());
result.put("waybillNo", source.getWaybillNo()); result.put("waybillNo", source.getWaybillNo());
result.put("vehicleNo", source.getVehicleNo()); result.put("vehicleNo", source.getVehicleNo());
result.put("departureAddress", waybill == null ? "" : result.put("departureAddress", Func.isNotEmpty(source.getDepartureAddress()) ? source.getDepartureAddress()
firstNotEmpty(waybill.getDepartureAddress(), waybill.getDepartureName())); : waybill == null ? "" : firstNotEmpty(waybill.getDepartureAddress(), waybill.getDepartureName()));
result.put("arrivalAddress", waybill == null ? "" : result.put("arrivalAddress", Func.isNotEmpty(source.getArrivalAddress()) ? source.getArrivalAddress()
firstNotEmpty(waybill.getArrivalAddress(), waybill.getArrivalName())); : waybill == null ? "" : firstNotEmpty(waybill.getArrivalAddress(), waybill.getArrivalName()));
result.put("departureContact", Func.isNotEmpty(source.getDepartureContact()) ? source.getDepartureContact()
: waybill == null ? "" : waybill.getDepartureContact());
result.put("departurePhone", Func.isNotEmpty(source.getDeparturePhone()) ? source.getDeparturePhone()
: waybill == null ? "" : waybill.getDeparturePhone());
result.put("arrivalContact", Func.isNotEmpty(source.getArrivalContact()) ? source.getArrivalContact()
: waybill == null ? "" : waybill.getArrivalContact());
result.put("arrivalPhone", Func.isNotEmpty(source.getArrivalPhone()) ? source.getArrivalPhone()
: waybill == null ? "" : waybill.getArrivalPhone());
result.put("actualDepartureTime", waybill == null || waybill.getStartDate() == null ? null : result.put("actualDepartureTime", waybill == null || waybill.getStartDate() == null ? null :
waybill.getStartDate().atStartOfDay()); waybill.getStartDate().atStartOfDay());
result.put("actualCompletionTime", waybill == null || waybill.getEndDate() == null ? null : result.put("actualCompletionTime", waybill == null || waybill.getEndDate() == null ? null :
@@ -832,6 +840,12 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
detail.setWaybillId(source.getWaybillId()); detail.setWaybillId(source.getWaybillId());
detail.setWaybillNo(source.getWaybillNo()); detail.setWaybillNo(source.getWaybillNo());
detail.setVehicleNo(source.getVehicleNo()); detail.setVehicleNo(source.getVehicleNo());
detail.setDepartureAddress(source.getDepartureAddress());
detail.setArrivalAddress(source.getArrivalAddress());
detail.setDepartureContact(source.getDepartureContact());
detail.setDeparturePhone(source.getDeparturePhone());
detail.setArrivalContact(source.getArrivalContact());
detail.setArrivalPhone(source.getArrivalPhone());
detail.setTransportType(source.getTransportType()); detail.setTransportType(source.getTransportType());
detail.setCargoName(source.getCargoName()); detail.setCargoName(source.getCargoName());
detail.setCargoType(source.getCargoType()); detail.setCargoType(source.getCargoType());
@@ -850,8 +864,16 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
detail.setRemark(source.getRemark()); detail.setRemark(source.getRemark());
Waybill waybill = source.getWaybillId() == null ? null : waybillService.getById(source.getWaybillId()); Waybill waybill = source.getWaybillId() == null ? null : waybillService.getById(source.getWaybillId());
if (waybill != null) { if (waybill != null) {
if (Func.isEmpty(detail.getDepartureAddress())) {
detail.setDepartureAddress(firstNotEmpty(waybill.getDepartureAddress(), waybill.getDepartureName())); detail.setDepartureAddress(firstNotEmpty(waybill.getDepartureAddress(), waybill.getDepartureName()));
}
if (Func.isEmpty(detail.getArrivalAddress())) {
detail.setArrivalAddress(firstNotEmpty(waybill.getArrivalAddress(), waybill.getArrivalName())); detail.setArrivalAddress(firstNotEmpty(waybill.getArrivalAddress(), waybill.getArrivalName()));
}
if (Func.isEmpty(detail.getDepartureContact())) detail.setDepartureContact(waybill.getDepartureContact());
if (Func.isEmpty(detail.getDeparturePhone())) detail.setDeparturePhone(waybill.getDeparturePhone());
if (Func.isEmpty(detail.getArrivalContact())) detail.setArrivalContact(waybill.getArrivalContact());
if (Func.isEmpty(detail.getArrivalPhone())) detail.setArrivalPhone(waybill.getArrivalPhone());
detail.setActualDepartureTime(waybill.getStartDate() == null ? null : waybill.getStartDate().atStartOfDay()); detail.setActualDepartureTime(waybill.getStartDate() == null ? null : waybill.getStartDate().atStartOfDay());
detail.setActualCompletionTime(waybill.getEndDate() == null ? null : waybill.getEndDate().atStartOfDay()); detail.setActualCompletionTime(waybill.getEndDate() == null ? null : waybill.getEndDate().atStartOfDay());
} }
@@ -1170,6 +1170,12 @@ public class ReceivablePayableDetailServiceImpl
detail.setWaybillId(waybill.getId()); detail.setWaybillId(waybill.getId());
detail.setWaybillNo(waybill.getWaybillNo()); detail.setWaybillNo(waybill.getWaybillNo());
detail.setVehicleNo(waybill.getVehicleNo()); detail.setVehicleNo(waybill.getVehicleNo());
detail.setDepartureAddress(waybill.getDepartureAddress());
detail.setArrivalAddress(waybill.getArrivalAddress());
detail.setDepartureContact(waybill.getDepartureContact());
detail.setDeparturePhone(waybill.getDeparturePhone());
detail.setArrivalContact(waybill.getArrivalContact());
detail.setArrivalPhone(waybill.getArrivalPhone());
detail.setTransportType(waybill.getTransportType()); detail.setTransportType(waybill.getTransportType());
detail.setCargoName(waybill.getCargoName()); detail.setCargoName(waybill.getCargoName());
detail.setCargoType(waybill.getCargoType()); detail.setCargoType(waybill.getCargoType());
@@ -1268,8 +1274,12 @@ public class ReceivablePayableDetailServiceImpl
masterGoodsItem.setQuantityUnit(stringValue(goods, "quantityUnit")); masterGoodsItem.setQuantityUnit(stringValue(goods, "quantityUnit"));
masterGoodsItem.setDepartureName(masterOrder.getDepartureName()); masterGoodsItem.setDepartureName(masterOrder.getDepartureName());
masterGoodsItem.setDepartureAddress(masterOrder.getDepartureAddress()); masterGoodsItem.setDepartureAddress(masterOrder.getDepartureAddress());
masterGoodsItem.setDepartureContact(masterOrder.getDepartureContact());
masterGoodsItem.setDeparturePhone(masterOrder.getDeparturePhone());
masterGoodsItem.setArrivalName(masterOrder.getArrivalName()); masterGoodsItem.setArrivalName(masterOrder.getArrivalName());
masterGoodsItem.setArrivalAddress(masterOrder.getArrivalAddress()); masterGoodsItem.setArrivalAddress(masterOrder.getArrivalAddress());
masterGoodsItem.setArrivalContact(masterOrder.getArrivalContact());
masterGoodsItem.setArrivalPhone(masterOrder.getArrivalPhone());
masterGoodsItem.setEndDate(masterOrder.getPlanEndTime() == null ? LocalDate.now() masterGoodsItem.setEndDate(masterOrder.getPlanEndTime() == null ? LocalDate.now()
: masterOrder.getPlanEndTime().toLocalDate()); : masterOrder.getPlanEndTime().toLocalDate());
masterGoodsItem.setMasterNo(masterOrder.getMasterNo()); masterGoodsItem.setMasterNo(masterOrder.getMasterNo());
@@ -2373,8 +2383,10 @@ public class ReceivablePayableDetailServiceImpl
map.put("cargoInfo", waybill.getCargoName()); map.put("cargoInfo", waybill.getCargoName());
map.put("departureAddress", waybill.getDepartureAddress()); map.put("departureAddress", waybill.getDepartureAddress());
map.put("departureContact", waybill.getDepartureContact()); map.put("departureContact", waybill.getDepartureContact());
map.put("departurePhone", waybill.getDeparturePhone());
map.put("arrivalAddress", waybill.getArrivalAddress()); map.put("arrivalAddress", waybill.getArrivalAddress());
map.put("arrivalContact", waybill.getArrivalContact()); map.put("arrivalContact", waybill.getArrivalContact());
map.put("arrivalPhone", waybill.getArrivalPhone());
map.put("unitPrice", waybill.getUnitPrice()); map.put("unitPrice", waybill.getUnitPrice());
map.put("freight", waybillFreight(waybill)); map.put("freight", waybillFreight(waybill));
map.put("otherFeeTotal", waybillOtherFee(waybill)); map.put("otherFeeTotal", waybillOtherFee(waybill));
@@ -2479,6 +2491,12 @@ public class ReceivablePayableDetailServiceImpl
map.put("formalSettlementNo", detail.getFormalSettlementNo()); map.put("formalSettlementNo", detail.getFormalSettlementNo());
map.put("waybillNo", detail.getWaybillNo()); map.put("waybillNo", detail.getWaybillNo());
map.put("vehicleNo", detail.getVehicleNo()); map.put("vehicleNo", detail.getVehicleNo());
map.put("departureAddress", detail.getDepartureAddress());
map.put("arrivalAddress", detail.getArrivalAddress());
map.put("departureContact", detail.getDepartureContact());
map.put("departurePhone", detail.getDeparturePhone());
map.put("arrivalContact", detail.getArrivalContact());
map.put("arrivalPhone", detail.getArrivalPhone());
map.put("transportType", detail.getTransportType()); map.put("transportType", detail.getTransportType());
map.put("cargoName", detail.getCargoName()); map.put("cargoName", detail.getCargoName());
map.put("cargoType", detail.getCargoType()); map.put("cargoType", detail.getCargoType());
@@ -68,6 +68,10 @@ CREATE TABLE IF NOT EXISTS `blade_formal_settlement_detail` (
`source_pre_settlement_detail_id` bigint(20) DEFAULT NULL, `source_detail_id` bigint(20) NOT NULL, `line_no` int(11) NOT NULL, `source_pre_settlement_detail_id` bigint(20) DEFAULT NULL, `source_detail_id` bigint(20) NOT NULL, `line_no` int(11) NOT NULL,
`document_no` varchar(100) DEFAULT NULL, `waybill_id` bigint(20) DEFAULT NULL, `waybill_no` varchar(100) DEFAULT NULL, `document_no` varchar(100) DEFAULT NULL, `waybill_id` bigint(20) DEFAULT NULL, `waybill_no` varchar(100) DEFAULT NULL,
`vehicle_no` varchar(100) DEFAULT NULL, `departure_address` varchar(500) DEFAULT NULL, `arrival_address` varchar(500) DEFAULT NULL, `vehicle_no` varchar(100) DEFAULT NULL, `departure_address` varchar(500) DEFAULT NULL, `arrival_address` varchar(500) DEFAULT NULL,
`departure_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人',
`departure_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式',
`arrival_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人',
`arrival_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式',
`actual_departure_time` datetime DEFAULT NULL, `actual_completion_time` datetime DEFAULT NULL, `transport_type` varchar(100) DEFAULT NULL, `actual_departure_time` datetime DEFAULT NULL, `actual_completion_time` datetime DEFAULT NULL, `transport_type` varchar(100) DEFAULT NULL,
`cargo_name` varchar(500) DEFAULT NULL, `cargo_type` varchar(500) DEFAULT NULL, `transport_quantity` decimal(18,6) DEFAULT NULL, `cargo_name` varchar(500) DEFAULT NULL, `cargo_type` varchar(500) DEFAULT NULL, `transport_quantity` decimal(18,6) DEFAULT NULL,
`quantity_unit` varchar(50) DEFAULT NULL, `mileage` decimal(18,2) DEFAULT NULL, `batch_no` varchar(100) DEFAULT NULL, `quantity_unit` varchar(50) DEFAULT NULL, `mileage` decimal(18,2) DEFAULT NULL, `batch_no` varchar(100) DEFAULT NULL,
@@ -66,7 +66,11 @@ CREATE TABLE IF NOT EXISTS `blade_pre_settlement_detail` (
`waybill_no` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '运单号', `waybill_no` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '运单号',
`vehicle_no` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车号', `vehicle_no` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车号',
`departure_address` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货地址', `departure_address` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货地址',
`arrival_address` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '货地址', `arrival_address` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '货地址',
`departure_contact` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人',
`departure_phone` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式',
`arrival_contact` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人',
`arrival_phone` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式',
`actual_departure_time` datetime DEFAULT NULL COMMENT '实际发货时间', `actual_departure_time` datetime DEFAULT NULL COMMENT '实际发货时间',
`actual_completion_time` datetime DEFAULT NULL COMMENT '实际完成时间', `actual_completion_time` datetime DEFAULT NULL COMMENT '实际完成时间',
`transport_type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '运输类型', `transport_type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '运输类型',
@@ -27,6 +27,12 @@ CREATE TABLE IF NOT EXISTS `blade_receivable_payable_detail` (
`waybill_id` bigint(20) DEFAULT NULL COMMENT '运单ID', `waybill_id` bigint(20) DEFAULT NULL COMMENT '运单ID',
`waybill_no` varchar(100) DEFAULT NULL COMMENT '运单号', `waybill_no` varchar(100) DEFAULT NULL COMMENT '运单号',
`vehicle_no` varchar(100) DEFAULT NULL COMMENT '车号', `vehicle_no` varchar(100) DEFAULT NULL COMMENT '车号',
`departure_address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货地址',
`arrival_address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货地址',
`departure_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人',
`departure_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式',
`arrival_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人',
`arrival_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式',
`transport_type` varchar(100) DEFAULT NULL COMMENT '运输类型', `transport_type` varchar(100) DEFAULT NULL COMMENT '运输类型',
`cargo_name` varchar(100) DEFAULT NULL COMMENT '货物名称', `cargo_name` varchar(100) DEFAULT NULL COMMENT '货物名称',
`cargo_type` varchar(100) DEFAULT NULL COMMENT '货物类型', `cargo_type` varchar(100) DEFAULT NULL COMMENT '货物类型',
@@ -49,7 +55,7 @@ CREATE TABLE IF NOT EXISTS `blade_receivable_payable_detail` (
KEY `idx_receivable_payable_contract` (`contract_id`) USING BTREE, KEY `idx_receivable_payable_contract` (`contract_id`) USING BTREE,
KEY `idx_receivable_payable_waybill` (`waybill_id`) USING BTREE, KEY `idx_receivable_payable_waybill` (`waybill_id`) USING BTREE,
KEY `idx_receivable_payable_status` (`settlement_status`) USING BTREE KEY `idx_receivable_payable_status` (`settlement_status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应收应付明细'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='应收应付明细';
CREATE TABLE IF NOT EXISTS `blade_receivable_payable_cargo_fee` ( CREATE TABLE IF NOT EXISTS `blade_receivable_payable_cargo_fee` (
`id` bigint(20) NOT NULL COMMENT '主键', `id` bigint(20) NOT NULL COMMENT '主键',
@@ -0,0 +1,91 @@
-- 应收应付、预结算及正式结算明细补充收发货地址、联系人及联系方式。
-- MySQL 5.7+ 兼容,可重复执行。
DELIMITER $$
DROP PROCEDURE IF EXISTS `upgrade_settlement_detail_address_contact_20260909`$$
CREATE PROCEDURE `upgrade_settlement_detail_address_contact_20260909`()
BEGIN
DECLARE db_name varchar(128);
SET db_name = DATABASE();
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'departure_address') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `departure_address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货地址' AFTER `vehicle_no`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'arrival_address') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `arrival_address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货地址' AFTER `departure_address`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'departure_contact') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `departure_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人' AFTER `arrival_address`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'departure_phone') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `departure_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式' AFTER `departure_contact`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'arrival_contact') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `arrival_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人' AFTER `departure_phone`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_receivable_payable_detail' AND column_name = 'arrival_phone') THEN
ALTER TABLE `blade_receivable_payable_detail` ADD COLUMN `arrival_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式' AFTER `arrival_contact`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_pre_settlement_detail' AND column_name = 'departure_contact') THEN
ALTER TABLE `blade_pre_settlement_detail` ADD COLUMN `departure_contact` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人' AFTER `arrival_address`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_pre_settlement_detail' AND column_name = 'departure_phone') THEN
ALTER TABLE `blade_pre_settlement_detail` ADD COLUMN `departure_phone` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式' AFTER `departure_contact`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_pre_settlement_detail' AND column_name = 'arrival_contact') THEN
ALTER TABLE `blade_pre_settlement_detail` ADD COLUMN `arrival_contact` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人' AFTER `departure_phone`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_pre_settlement_detail' AND column_name = 'arrival_phone') THEN
ALTER TABLE `blade_pre_settlement_detail` ADD COLUMN `arrival_phone` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式' AFTER `arrival_contact`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_formal_settlement_detail' AND column_name = 'departure_contact') THEN
ALTER TABLE `blade_formal_settlement_detail` ADD COLUMN `departure_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系人' AFTER `arrival_address`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_formal_settlement_detail' AND column_name = 'departure_phone') THEN
ALTER TABLE `blade_formal_settlement_detail` ADD COLUMN `departure_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发货联系方式' AFTER `departure_contact`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_formal_settlement_detail' AND column_name = 'arrival_contact') THEN
ALTER TABLE `blade_formal_settlement_detail` ADD COLUMN `arrival_contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系人' AFTER `departure_phone`;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = db_name AND table_name = 'blade_formal_settlement_detail' AND column_name = 'arrival_phone') THEN
ALTER TABLE `blade_formal_settlement_detail` ADD COLUMN `arrival_phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '收货联系方式' AFTER `arrival_contact`;
END IF;
UPDATE `blade_receivable_payable_detail` source_detail
INNER JOIN `blade_waybill` waybill ON waybill.`id` = source_detail.`waybill_id` AND waybill.`is_deleted` = 0
SET source_detail.`departure_address` = COALESCE(NULLIF(source_detail.`departure_address`, ''), NULLIF(waybill.`departure_address`, ''), waybill.`departure_name`),
source_detail.`arrival_address` = COALESCE(NULLIF(source_detail.`arrival_address`, ''), NULLIF(waybill.`arrival_address`, ''), waybill.`arrival_name`),
source_detail.`departure_contact` = COALESCE(NULLIF(source_detail.`departure_contact`, ''), waybill.`departure_contact`),
source_detail.`departure_phone` = COALESCE(NULLIF(source_detail.`departure_phone`, ''), waybill.`departure_phone`),
source_detail.`arrival_contact` = COALESCE(NULLIF(source_detail.`arrival_contact`, ''), waybill.`arrival_contact`),
source_detail.`arrival_phone` = COALESCE(NULLIF(source_detail.`arrival_phone`, ''), waybill.`arrival_phone`)
WHERE source_detail.`is_deleted` = 0;
UPDATE `blade_pre_settlement_detail` target_detail
INNER JOIN `blade_receivable_payable_detail` source_detail ON source_detail.`id` = target_detail.`source_detail_id`
SET target_detail.`departure_address` = COALESCE(NULLIF(target_detail.`departure_address`, ''), source_detail.`departure_address`),
target_detail.`arrival_address` = COALESCE(NULLIF(target_detail.`arrival_address`, ''), source_detail.`arrival_address`),
target_detail.`departure_contact` = COALESCE(NULLIF(target_detail.`departure_contact`, ''), source_detail.`departure_contact`),
target_detail.`departure_phone` = COALESCE(NULLIF(target_detail.`departure_phone`, ''), source_detail.`departure_phone`),
target_detail.`arrival_contact` = COALESCE(NULLIF(target_detail.`arrival_contact`, ''), source_detail.`arrival_contact`),
target_detail.`arrival_phone` = COALESCE(NULLIF(target_detail.`arrival_phone`, ''), source_detail.`arrival_phone`)
WHERE target_detail.`is_deleted` = 0 AND source_detail.`is_deleted` = 0;
UPDATE `blade_formal_settlement_detail` target_detail
INNER JOIN `blade_receivable_payable_detail` source_detail ON source_detail.`id` = target_detail.`source_detail_id`
SET target_detail.`departure_address` = COALESCE(NULLIF(target_detail.`departure_address`, ''), source_detail.`departure_address`),
target_detail.`arrival_address` = COALESCE(NULLIF(target_detail.`arrival_address`, ''), source_detail.`arrival_address`),
target_detail.`departure_contact` = COALESCE(NULLIF(target_detail.`departure_contact`, ''), source_detail.`departure_contact`),
target_detail.`departure_phone` = COALESCE(NULLIF(target_detail.`departure_phone`, ''), source_detail.`departure_phone`),
target_detail.`arrival_contact` = COALESCE(NULLIF(target_detail.`arrival_contact`, ''), source_detail.`arrival_contact`),
target_detail.`arrival_phone` = COALESCE(NULLIF(target_detail.`arrival_phone`, ''), source_detail.`arrival_phone`)
WHERE target_detail.`is_deleted` = 0 AND source_detail.`is_deleted` = 0;
END$$
CALL `upgrade_settlement_detail_address_contact_20260909`()$$
DROP PROCEDURE `upgrade_settlement_detail_address_contact_20260909`$$
DELIMITER ;