Compare commits
7 Commits
c2d2407262
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d322fe830e | |||
| c67f458c84 | |||
| fbe32b6e65 | |||
| d048f3fcf1 | |||
| bc690863c6 | |||
| 89ddd188b6 | |||
| 3c908eb895 |
@@ -113,8 +113,8 @@ public class DeliveryOrderController extends BaseController {
|
|||||||
@PreAuthorize("@ss.hasPermi('document:order:add')")
|
@PreAuthorize("@ss.hasPermi('document:order:add')")
|
||||||
@Log(title = "配送单据主-保存(含附件)", businessType = BusinessType.INSERT)
|
@Log(title = "配送单据主-保存(含附件)", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public AjaxResult save(@RequestBody DeliveryOrderSaveDTO dto) {
|
public AjaxResult save(@RequestBody DeliveryOrderSaveDTO dto) {;
|
||||||
String username = "大爷的!";
|
String username = getUsername();
|
||||||
int rows = deliveryOrderService.saveOrderWithAttachments(dto, username);
|
int rows = deliveryOrderService.saveOrderWithAttachments(dto, username);
|
||||||
return toAjax(rows);
|
return toAjax(rows);
|
||||||
}
|
}
|
||||||
@@ -148,8 +148,8 @@ public class DeliveryOrderController extends BaseController {
|
|||||||
* 从智慧实物系统拉取待配送出库单据列表
|
* 从智慧实物系统拉取待配送出库单据列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/wisdom/rk/list")
|
@GetMapping("/wisdom/rk/list")
|
||||||
public AjaxResult listRkFromWisdom(String billNoCk) {
|
public AjaxResult listRkFromWisdom(String billNo) {
|
||||||
List<DeliveryBillVO> list = deliveryOrderService.listWisdomRkForDelivery(billNoCk);
|
List<DeliveryBillVO> list = deliveryOrderService.listWisdomRkForDelivery(billNo);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
@Excel(name = "配送单据号")
|
@Excel(name = "配送单据号")
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
|
||||||
/** rk_info主键ID */
|
/** rk_record主键ID */
|
||||||
// @Excel(name = "rk_info主键ID")
|
private Long rkRecordId;
|
||||||
private Long rkInfoId;
|
|
||||||
|
|
||||||
/** 制单人用户ID */
|
/** 制单人用户ID */
|
||||||
// @Excel(name = "制单人ID")
|
// @Excel(name = "制单人ID")
|
||||||
@@ -44,9 +43,8 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
@Excel(name = "存在问题描述")
|
@Excel(name = "存在问题描述")
|
||||||
private String receiveProblem;
|
private String receiveProblem;
|
||||||
|
|
||||||
/** 出库单据号 */
|
/** 单据号(对应 rk_record.bill_no) */
|
||||||
// @Excel(name = "出库单据号")
|
private String billNo;
|
||||||
private String billNoCk;
|
|
||||||
|
|
||||||
/** 项目描述 */
|
/** 项目描述 */
|
||||||
// @Excel(name = "项目描述")
|
// @Excel(name = "项目描述")
|
||||||
@@ -188,6 +186,9 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
@Excel(name = "总公里数")
|
@Excel(name = "总公里数")
|
||||||
private BigDecimal totalKm;
|
private BigDecimal totalKm;
|
||||||
|
|
||||||
|
@Excel(name = "主键ID")
|
||||||
|
private Long rkInfoId;
|
||||||
|
|
||||||
// ===================== Getter & Setter =====================
|
// ===================== Getter & Setter =====================
|
||||||
|
|
||||||
public Long getId() { return id; }
|
public Long getId() { return id; }
|
||||||
@@ -196,8 +197,12 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
public String getOrderNo() { return orderNo; }
|
public String getOrderNo() { return orderNo; }
|
||||||
public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
|
public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
|
||||||
|
|
||||||
public Long getRkInfoId() { return rkInfoId; }
|
public Long getRkRecordId() {
|
||||||
public void setRkInfoId(Long rkInfoId) { this.rkInfoId = rkInfoId; }
|
return rkRecordId;
|
||||||
|
}
|
||||||
|
public void setRkRecordId(Long rkRecordId) {
|
||||||
|
this.rkRecordId = rkRecordId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMakerUserName() {
|
public String getMakerUserName() {
|
||||||
return makerUserName;
|
return makerUserName;
|
||||||
@@ -206,6 +211,9 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
this.makerUserName = makerUserName;
|
this.makerUserName = makerUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getRkInfoId() { return rkInfoId; }
|
||||||
|
public void setRkInfoId(Long rkInfoId) { this.rkInfoId = rkInfoId; }
|
||||||
|
|
||||||
public Long getMakerId() { return makerId; }
|
public Long getMakerId() { return makerId; }
|
||||||
public void setMakerId(Long makerId) { this.makerId = makerId; }
|
public void setMakerId(Long makerId) { this.makerId = makerId; }
|
||||||
|
|
||||||
@@ -219,8 +227,12 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
public String getReceiveProblem() { return receiveProblem; }
|
public String getReceiveProblem() { return receiveProblem; }
|
||||||
public void setReceiveProblem(String receiveProblem) { this.receiveProblem = receiveProblem; }
|
public void setReceiveProblem(String receiveProblem) { this.receiveProblem = receiveProblem; }
|
||||||
|
|
||||||
public String getBillNoCk() { return billNoCk; }
|
public String getBillNo() {
|
||||||
public void setBillNoCk(String billNoCk) { this.billNoCk = billNoCk; }
|
return billNo;
|
||||||
|
}
|
||||||
|
public void setBillNo(String billNo) {
|
||||||
|
this.billNo = billNo;
|
||||||
|
}
|
||||||
|
|
||||||
public String getXmMs() { return xmMs; }
|
public String getXmMs() { return xmMs; }
|
||||||
public void setXmMs(String xmMs) { this.xmMs = xmMs; }
|
public void setXmMs(String xmMs) { this.xmMs = xmMs; }
|
||||||
@@ -326,7 +338,6 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
|
|
||||||
public BigDecimal getTotalKm() { return totalKm; }
|
public BigDecimal getTotalKm() { return totalKm; }
|
||||||
public void setTotalKm(BigDecimal totalKm) { this.totalKm = totalKm; }
|
public void setTotalKm(BigDecimal totalKm) { this.totalKm = totalKm; }
|
||||||
|
|
||||||
// ===================== toString =====================
|
// ===================== toString =====================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -334,12 +345,12 @@ public class DeliveryOrder extends BaseEntity {
|
|||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
.append("orderNo", getOrderNo())
|
.append("orderNo", getOrderNo())
|
||||||
.append("rkInfoId", getRkInfoId())
|
.append("rkRecordId", getRkRecordId())
|
||||||
.append("makerId", getMakerId())
|
.append("makerId", getMakerId())
|
||||||
.append("makerUserName", getMakerUserName())
|
.append("makerUserName", getMakerUserName())
|
||||||
.append("receiveStatus", getReceiveStatus()) // *** 类型已是 Integer ***
|
.append("receiveStatus", getReceiveStatus()) // *** 类型已是 Integer ***
|
||||||
.append("receiveProblem", getReceiveProblem())
|
.append("receiveProblem", getReceiveProblem())
|
||||||
.append("billNoCk", getBillNoCk())
|
.append("billNo", getBillNo())
|
||||||
.append("xmMs", getXmMs())
|
.append("xmMs", getXmMs())
|
||||||
.append("xmNo", getXmNo())
|
.append("xmNo", getXmNo())
|
||||||
.append("wlNo", getWlNo())
|
.append("wlNo", getWlNo())
|
||||||
|
|||||||
@@ -7,14 +7,17 @@ import java.math.BigDecimal;
|
|||||||
@Data
|
@Data
|
||||||
public class DeliveryOrderLineDTO {
|
public class DeliveryOrderLineDTO {
|
||||||
|
|
||||||
/**
|
|
||||||
* 对应智慧实物系统 rk_info 表的主键 ID
|
|
||||||
* detailList 里的 id 就是这个值
|
|
||||||
*/
|
|
||||||
private Long rkInfoId;
|
|
||||||
|
|
||||||
/** 出库单据号 */
|
/**
|
||||||
private String billNoCk;
|
* 对应智慧实物系统 rk_record 表主键 ID
|
||||||
|
*/
|
||||||
|
private Long rkRecordId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据号(以 rk_record.bill_no 为准)
|
||||||
|
* 说明:出库生成配送单时,所有行必须属于同一 billNo
|
||||||
|
*/
|
||||||
|
private String billNo;
|
||||||
|
|
||||||
/** 项目描述 */
|
/** 项目描述 */
|
||||||
private String xmMs;
|
private String xmMs;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class DeliveryOrderGroupVO {
|
|||||||
/** 配送单号 */
|
/** 配送单号 */
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
/** 出库单据号 */
|
/** 出库单据号 */
|
||||||
private String billNoCk;
|
private String billNo;
|
||||||
/** 配送日期(格式:yyyy-MM-dd) */
|
/** 配送日期(格式:yyyy-MM-dd) */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date deliveryDate;
|
private Date deliveryDate;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class DeliveryOrderVo {
|
|||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
|
||||||
/** 出库单据号 */
|
/** 出库单据号 */
|
||||||
private String billNoCk;
|
private String billNo;
|
||||||
|
|
||||||
/** 起始地点名称 */
|
/** 起始地点名称 */
|
||||||
private String originName;
|
private String originName;
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public interface IDeliveryOrderService {
|
|||||||
/** 详情:按单号查行 */
|
/** 详情:按单号查行 */
|
||||||
List<DeliveryOrderDetailVO> listByOrderNo(String orderNo);
|
List<DeliveryOrderDetailVO> listByOrderNo(String orderNo);
|
||||||
|
|
||||||
/** 从智慧实物系统查询待配送出库单据(可按出库单号 billNoCk 过滤) */
|
/** 从智慧实物系统查询待配送出库单据(可按出库单号 billNo 过滤) */
|
||||||
List<DeliveryBillVO> listWisdomRkForDelivery(String billNoCk);
|
List<DeliveryBillVO> listWisdomRkForDelivery(String billNo);
|
||||||
|
|
||||||
// ======================== 统计 ========================
|
// ======================== 统计 ========================
|
||||||
|
|
||||||
|
|||||||
@@ -141,43 +141,47 @@ public class DeliveryAttachmentServiceImpl implements IDeliveryAttachmentService
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int executeBind(DeliveryExecuteBindDTO dto) {
|
public int executeBind(DeliveryExecuteBindDTO dto) {
|
||||||
|
|
||||||
// 0) 基础校验
|
// ====================== 0. 基础校验 ======================
|
||||||
if (dto == null || StringUtils.isBlank(dto.getOrderNo())) {
|
if (dto == null || StringUtils.isBlank(dto.getOrderNo())) {
|
||||||
throw new ServiceException("订单号不能为空");
|
throw new ServiceException("订单号不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1) 校验订单存在(一个单号多行)
|
// ====================== 1. 校验配送单是否存在 ======================
|
||||||
List<DeliveryOrder> existList = deliveryOrderMapper.selectDeliveryOrderByOrderNo(dto.getOrderNo());
|
List<DeliveryOrder> existList =
|
||||||
|
deliveryOrderMapper.selectDeliveryOrderByOrderNo(dto.getOrderNo());
|
||||||
|
|
||||||
if (existList == null || existList.isEmpty()) {
|
if (existList == null || existList.isEmpty()) {
|
||||||
throw new ServiceException("配送单不存在:" + dto.getOrderNo());
|
throw new ServiceException("配送单不存在:" + dto.getOrderNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== 从配送单中拿到所有 rk_info_id 列表(允许为空:手工配送单场景) ======
|
// ====================== 2. 收集 rk_record_id ======================
|
||||||
List<Long> rkInfoIdList = existList.stream()
|
List<Long> rkRecordIdList = existList.stream()
|
||||||
.map(DeliveryOrder::getRkInfoId)
|
.map(DeliveryOrder::getRkRecordId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (rkInfoIdList.isEmpty()) {
|
if (rkRecordIdList.isEmpty()) {
|
||||||
// 手工创建的配送单可能没有绑定 rk_info_id:允许为空,后续只跳过 WMS 回写
|
log.warn("配送单未绑定 rk_record_id,将跳过 WMS 回写。orderNo={}",
|
||||||
log.warn("配送单未绑定 rk_info_id,将跳过 WMS 库存状态回写。orderNo={}", dto.getOrderNo());
|
dto.getOrderNo());
|
||||||
}
|
}
|
||||||
// ======================================================================
|
|
||||||
|
|
||||||
|
// ====================== 3. 附件校验 ======================
|
||||||
if (dto.getAttachments() == null || dto.getAttachments().isEmpty()) {
|
if (dto.getAttachments() == null || dto.getAttachments().isEmpty()) {
|
||||||
throw new ServiceException("附件列表不能为空");
|
throw new ServiceException("附件列表不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) 批量插入附件(只传 URL)
|
// ====================== 4. 批量插入附件 ======================
|
||||||
List<DeliveryAttachment> list = new ArrayList<>();
|
List<DeliveryAttachment> list = new ArrayList<>();
|
||||||
String username = getUsername();
|
String username = getUsername();
|
||||||
|
|
||||||
for (DeliveryAttachItemDTO it : dto.getAttachments()) {
|
for (DeliveryAttachItemDTO it : dto.getAttachments()) {
|
||||||
if (it == null) {
|
|
||||||
continue;
|
if (it == null) continue;
|
||||||
}
|
|
||||||
if (it.getScene() == null || it.getBizType() == null || it.getUrl() == null) {
|
if (it.getScene() == null ||
|
||||||
|
it.getBizType() == null ||
|
||||||
|
it.getUrl() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,38 +192,72 @@ public class DeliveryAttachmentServiceImpl implements IDeliveryAttachmentService
|
|||||||
a.setUrl(it.getUrl());
|
a.setUrl(it.getUrl());
|
||||||
a.setSortNo(it.getSortNo());
|
a.setSortNo(it.getSortNo());
|
||||||
a.setRemark(it.getRemark());
|
a.setRemark(it.getRemark());
|
||||||
|
|
||||||
a.setStatus("1"); // 已绑定
|
a.setStatus("1"); // 已绑定
|
||||||
a.setIsDelete("0");
|
a.setIsDelete("0");
|
||||||
a.setCreateBy(username);
|
a.setCreateBy(username);
|
||||||
a.setCreateTime(DateUtils.getNowDate());
|
a.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
list.add(a);
|
list.add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
throw new ServiceException("有效附件条目为空");
|
throw new ServiceException("有效附件条目为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
deliveryAttachmentMapper.batchInsert(list);
|
deliveryAttachmentMapper.batchInsert(list);
|
||||||
|
|
||||||
// 3) 回写配送单(仅填需要更新的字段),交给已有 updateDeliveryOrder(按 order_no 更新)
|
// ====================== 5. 回写配送单 ======================
|
||||||
DeliveryOrder patch = new DeliveryOrder();
|
DeliveryOrder patch = new DeliveryOrder();
|
||||||
patch.setOrderNo(dto.getOrderNo());
|
patch.setOrderNo(dto.getOrderNo());
|
||||||
|
|
||||||
String scene = dto.getScene() == null ? "" : dto.getScene().toUpperCase(Locale.ROOT);
|
String scene = dto.getScene() == null
|
||||||
|
? ""
|
||||||
|
: dto.getScene().toUpperCase(Locale.ROOT);
|
||||||
|
|
||||||
|
// ====================== ORIGIN:开始配送 ======================
|
||||||
if ("ORIGIN".equals(scene)) {
|
if ("ORIGIN".equals(scene)) {
|
||||||
// 起点:司机信息 + 起点经纬度 + 状态=2(起运/配送中)
|
|
||||||
if (dto.getDriverName() != null) patch.setDriverName(dto.getDriverName());
|
if (dto.getDriverName() != null)
|
||||||
if (dto.getDriverPhone() != null) patch.setDriverPhone(dto.getDriverPhone());
|
patch.setDriverName(dto.getDriverName());
|
||||||
if (dto.getPlateNo() != null) patch.setPlateNo(dto.getPlateNo());
|
|
||||||
if (dto.getLng() != null) patch.setOriginLng(BigDecimal.valueOf(dto.getLng()));
|
if (dto.getDriverPhone() != null)
|
||||||
if (dto.getLat() != null) patch.setOriginLat(BigDecimal.valueOf(dto.getLat()));
|
patch.setDriverPhone(dto.getDriverPhone());
|
||||||
|
|
||||||
|
if (dto.getPlateNo() != null)
|
||||||
|
patch.setPlateNo(dto.getPlateNo());
|
||||||
|
|
||||||
|
if (dto.getLng() != null)
|
||||||
|
patch.setOriginLng(BigDecimal.valueOf(dto.getLng()));
|
||||||
|
|
||||||
|
if (dto.getLat() != null)
|
||||||
|
patch.setOriginLat(BigDecimal.valueOf(dto.getLat()));
|
||||||
|
|
||||||
|
// 本系统状态:配送中
|
||||||
patch.setOrderStatus("2");
|
patch.setOrderStatus("2");
|
||||||
|
|
||||||
} else if ("DEST".equals(scene)) {
|
// 🔥 回写 WMS:3 = 配送中
|
||||||
// 终点:终点经纬度 + 费用 + 状态=3(已完成)
|
if (rkRecordIdList != null && !rkRecordIdList.isEmpty()) {
|
||||||
if (dto.getLng() != null) patch.setDestLng(BigDecimal.valueOf(dto.getLng()));
|
|
||||||
if (dto.getLat() != null) patch.setDestLat(BigDecimal.valueOf(dto.getLat()));
|
|
||||||
|
|
||||||
|
boolean ok = updateWmsRecordIsDeliveryByIds(rkRecordIdList, 3);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
throw new ServiceException(
|
||||||
|
"回写 WMS 为【配送中】失败,rk_record_id=" + rkRecordIdList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// ====================== DEST:完成配送 ======================
|
||||||
|
else if ("DEST".equals(scene)) {
|
||||||
|
|
||||||
|
if (dto.getLng() != null)
|
||||||
|
patch.setDestLng(BigDecimal.valueOf(dto.getLng()));
|
||||||
|
|
||||||
|
if (dto.getLat() != null)
|
||||||
|
patch.setDestLat(BigDecimal.valueOf(dto.getLat()));
|
||||||
|
|
||||||
|
// 费用校验
|
||||||
if (dto.getActualFee() != null) {
|
if (dto.getActualFee() != null) {
|
||||||
if (dto.getActualFee().compareTo(BigDecimal.ZERO) < 0) {
|
if (dto.getActualFee().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
throw new ServiceException("实际费用不能为负数");
|
throw new ServiceException("实际费用不能为负数");
|
||||||
@@ -234,73 +272,72 @@ public class DeliveryAttachmentServiceImpl implements IDeliveryAttachmentService
|
|||||||
patch.setTollFee(dto.getTollFee());
|
patch.setTollFee(dto.getTollFee());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 接收状态校验
|
||||||
Integer receiveStatus = dto.getReceiveStatus();
|
Integer receiveStatus = dto.getReceiveStatus();
|
||||||
if (receiveStatus == null) {
|
if (receiveStatus == null) {
|
||||||
throw new ServiceException("完成配送时必须选择接收物资状态");
|
throw new ServiceException("完成配送时必须选择接收物资状态");
|
||||||
}
|
}
|
||||||
if (receiveStatus != 0 && receiveStatus != 1 && receiveStatus != 2) {
|
|
||||||
|
if (receiveStatus != 0 &&
|
||||||
|
receiveStatus != 1 &&
|
||||||
|
receiveStatus != 2) {
|
||||||
throw new ServiceException("接收物资状态不合法");
|
throw new ServiceException("接收物资状态不合法");
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.setReceiveStatus(receiveStatus);
|
patch.setReceiveStatus(receiveStatus);
|
||||||
|
|
||||||
if (receiveStatus == 2) {
|
if (receiveStatus == 2 &&
|
||||||
// 有问题必须写说明
|
StringUtils.isBlank(dto.getReceiveProblem())) {
|
||||||
if (StringUtils.isBlank(dto.getReceiveProblem())) {
|
|
||||||
throw new ServiceException("存在问题时必须填写问题描述");
|
throw new ServiceException("存在问题时必须填写问题描述");
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.setReceiveProblem(dto.getReceiveProblem());
|
patch.setReceiveProblem(dto.getReceiveProblem());
|
||||||
|
|
||||||
|
// 本系统状态:已完成
|
||||||
|
patch.setOrderStatus("3");
|
||||||
|
|
||||||
|
// 🔥 回写 WMS:4 = 配送完成
|
||||||
|
if (rkRecordIdList != null && !rkRecordIdList.isEmpty()) {
|
||||||
|
|
||||||
|
boolean ok = updateWmsRecordIsDeliveryByIds(rkRecordIdList, 4);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
throw new ServiceException(
|
||||||
|
"回写 WMS 为【配送完成】失败,rk_record_id=" + rkRecordIdList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.setOrderStatus("3"); // 已完成
|
|
||||||
} else {
|
} else {
|
||||||
// scene 既不是 ORIGIN 也不是 DEST:不强制报错,避免影响“仅绑定附件”的场景
|
log.warn("未识别 scene={},仅绑定附件", scene);
|
||||||
// 如果你希望严格校验,可以改为 throw new ServiceException("scene 不合法");
|
|
||||||
log.warn("executeBind 未识别的 scene={},将仅绑定附件并更新已有字段(如有)。orderNo={}", scene, dto.getOrderNo());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deliveryOrderMapper.updateDeliveryOrder(patch);
|
deliveryOrderMapper.updateDeliveryOrder(patch);
|
||||||
|
|
||||||
// 4) ⭐ 仅当 DEST 场景且存在 rk_info_id 绑定时,才远程调用 WMS 回写 is_delivery=3
|
|
||||||
if ("DEST".equals(scene)) {
|
|
||||||
|
|
||||||
if (rkInfoIdList != null && !rkInfoIdList.isEmpty()) {
|
|
||||||
boolean ok = updateWmsIsDeliveryByIds(rkInfoIdList, 3);
|
|
||||||
if (!ok) {
|
|
||||||
// 让整个事务回滚,附件 + 配送单状态都撤回
|
|
||||||
throw new ServiceException("回写 WMS 配送状态失败,rk_info_id 列表:" + rkInfoIdList);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 手工配送单:不回写 WMS
|
|
||||||
log.info("DEST 场景下配送单无 rk_info_id 绑定,跳过 WMS 回写。orderNo={}", dto.getOrderNo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.size();
|
return list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程调用智慧实物管理系统,按 rk_info 主键ID列表更新 is_delivery 状态
|
* 远程调用智慧实物管理系统
|
||||||
* 约定请求体结构:
|
* 更新 rk_record.is_delivery
|
||||||
* {
|
*
|
||||||
* "ids": [1, 2, 3],
|
* 0=不需要,1=需要,2=已接单,3=配送中,4=配送完成
|
||||||
* "isDelivery": 3
|
|
||||||
* }
|
|
||||||
*/
|
*/
|
||||||
private boolean updateWmsIsDeliveryByIds(List<Long> rkInfoIdList, int isDelivery) {
|
private boolean updateWmsRecordIsDeliveryByIds(List<Long> rkRecordIds, int isDelivery) {
|
||||||
|
|
||||||
String url = wisdomBaseUrl + "/wisdom/stock/updateDeliveryStatus";
|
String url = wisdomBaseUrl + "/wisdom/record/updateDeliveryStatus";
|
||||||
|
|
||||||
Map<String, Object> body = new HashMap<>();
|
Map<String, Object> body = new HashMap<>();
|
||||||
body.put("ids", rkInfoIdList);
|
body.put("ids", rkRecordIds);
|
||||||
body.put("isDelivery", isDelivery);
|
body.put("isDelivery", isDelivery);
|
||||||
|
|
||||||
String json = JSON.toJSONString(body);
|
String json = JSON.toJSONString(body);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String resp = HttpUtils.sendPost(url, json, MediaType.APPLICATION_JSON_VALUE);
|
String resp = HttpUtils.sendJsonPost(url, json);
|
||||||
|
|
||||||
if (StringUtils.isBlank(resp)) {
|
if (StringUtils.isBlank(resp)) {
|
||||||
log.error("WMS 更新失败,响应为空,url={} rkInfoIdList={}", url, rkInfoIdList);
|
log.error("WMS 更新失败,响应为空,ids={}", rkRecordIds);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,20 +346,23 @@ public class DeliveryAttachmentServiceImpl implements IDeliveryAttachmentService
|
|||||||
if (result != null && result.isSuccess()) {
|
if (result != null && result.isSuccess()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
String msg = (result == null)
|
String msg = result == null
|
||||||
? "响应为空"
|
? "响应为空"
|
||||||
: String.valueOf(result.get(AjaxResult.MSG_TAG));
|
: String.valueOf(result.get(AjaxResult.MSG_TAG));
|
||||||
log.error("WMS 更新失败,rkInfoIdList={},原因={}", rkInfoIdList, msg);
|
|
||||||
|
log.error("WMS 更新失败,ids={},原因={}", rkRecordIds, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("调用 WMS 接口异常,rkInfoIdList={},error={}", rkInfoIdList, e.getMessage(), e);
|
log.error("调用 WMS 接口异常,ids={},error={}",
|
||||||
|
rkRecordIds, e.getMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 保存目录 D:\delivery
|
// 保存目录 D:\delivery
|
||||||
private static final String BASE_PATH = "D:/delivery";
|
private static final String BASE_PATH = "D:/delivery";
|
||||||
|
|
||||||
|
|||||||
@@ -182,73 +182,47 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String createOrder(DeliveryOrderCreateDTO dto) {
|
public String createOrder(DeliveryOrderCreateDTO dto) {
|
||||||
|
|
||||||
// ========== 0. 参数校验 ==========
|
|
||||||
|
|
||||||
if (dto == null || dto.getItems() == null || dto.getItems().isEmpty()) {
|
if (dto == null || dto.getItems() == null || dto.getItems().isEmpty()) {
|
||||||
throw new ServiceException("物料明细不能为空");
|
throw new ServiceException("物料明细不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取第一条 billNoCk,判断是“手动创建”还是“出库单生成”
|
String billNo = dto.getItems().get(0).getBillNo();
|
||||||
String billNoCk = dto.getItems().get(0).getBillNoCk();
|
boolean fromWms = StringUtils.isNotBlank(billNo);
|
||||||
boolean fromWms = StringUtils.isNotBlank(billNoCk); // true = 出库单生成;false = 手动创建
|
|
||||||
|
|
||||||
// 收集 rk_info 主键 id(仅用于出库单生成场景回写 WMS)
|
List<Long> rkRecordIds = dto.getItems().stream()
|
||||||
List<Long> rkInfoIds = dto.getItems().stream()
|
.map(DeliveryOrderLineDTO::getRkRecordId)
|
||||||
.map(DeliveryOrderLineDTO::getRkInfoId)
|
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 出库单生成场景必须有 rkInfoId
|
if (fromWms && rkRecordIds.isEmpty()) {
|
||||||
if (fromWms && rkInfoIds.isEmpty()) {
|
throw new ServiceException("明细行缺少 rk_record 主键 id");
|
||||||
throw new ServiceException("明细行缺少 rk_info 主键 id,无法回写配送状态");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 1. 生成配送单号 ==========
|
|
||||||
|
|
||||||
String orderNo = StringUtils.isBlank(dto.getOrderNo())
|
String orderNo = StringUtils.isBlank(dto.getOrderNo())
|
||||||
? "DO" + DateUtils.dateTimeNow("yyyyMMddHHmmssSSS")
|
? "DO" + DateUtils.dateTimeNow("yyyyMMddHHmmssSSS")
|
||||||
: dto.getOrderNo().trim();
|
: dto.getOrderNo().trim();
|
||||||
|
|
||||||
Date now = DateUtils.getNowDate();
|
Date now = DateUtils.getNowDate();
|
||||||
String username = SecurityUtils.getUsername();
|
String username = SecurityUtils.getUsername();
|
||||||
Long currentUserId = null;
|
Long currentUserId = SecurityUtils.getUserId();
|
||||||
try {
|
Long makerId = dto.getMakerId() != null ? dto.getMakerId() : currentUserId;
|
||||||
currentUserId = SecurityUtils.getUserId();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("获取当前登录用户ID失败:{}", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 制单人用户ID:优先用前端传的 makerId,没有则回退到当前登录用户
|
|
||||||
Long makerId = dto.getMakerId();
|
|
||||||
if (makerId == null) {
|
|
||||||
if (currentUserId == null) {
|
|
||||||
throw new ServiceException("无法确定制单人用户ID,请重新登录后重试");
|
|
||||||
}
|
|
||||||
makerId = currentUserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<DeliveryOrder> rows = new ArrayList<>();
|
List<DeliveryOrder> rows = new ArrayList<>();
|
||||||
|
|
||||||
// ========== 2. 遍历每一条物料明细,组装行记录 ==========
|
|
||||||
|
|
||||||
for (DeliveryOrderLineDTO it : dto.getItems()) {
|
for (DeliveryOrderLineDTO it : dto.getItems()) {
|
||||||
|
|
||||||
// ===== 出库单生成场景下的两个判断(手动创建时跳过) =====
|
|
||||||
if (fromWms) {
|
if (fromWms) {
|
||||||
// 限制同一出库单
|
if (!billNo.equals(it.getBillNo())) {
|
||||||
if (!billNoCk.equals(it.getBillNoCk())) {
|
throw new ServiceException("暂不支持多单合并配送");
|
||||||
throw new ServiceException("当前接口暂不支持多张出库单合并配送,请确保所有明细 billNoCk 相同");
|
|
||||||
}
|
}
|
||||||
|
if (it.getRkRecordId() == null) {
|
||||||
if (it.getRkInfoId() == null) {
|
throw new ServiceException("明细缺少 rk_record_id");
|
||||||
throw new ServiceException("明细行缺少 rk_info 主键 id");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeliveryOrder row = new DeliveryOrder();
|
DeliveryOrder row = new DeliveryOrder();
|
||||||
|
|
||||||
// 2.1 公共头部字段(整单一致)
|
|
||||||
row.setOrderNo(orderNo);
|
row.setOrderNo(orderNo);
|
||||||
row.setOriginName(dto.getOriginName());
|
row.setOriginName(dto.getOriginName());
|
||||||
row.setOriginLng(dto.getOriginLng());
|
row.setOriginLng(dto.getOriginLng());
|
||||||
@@ -267,13 +241,11 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
row.setDeliveryTon(dto.getDeliveryTon());
|
row.setDeliveryTon(dto.getDeliveryTon());
|
||||||
row.setGoodsSize(dto.getGoodsSize());
|
row.setGoodsSize(dto.getGoodsSize());
|
||||||
|
|
||||||
// 制单人用户ID
|
|
||||||
row.setMakerId(makerId);
|
row.setMakerId(makerId);
|
||||||
|
row.setReceiveStatus(dto.getReceiveStatus());
|
||||||
|
row.setReceiveProblem(dto.getReceiveProblem());
|
||||||
|
|
||||||
// 配送状态:前端不传时默认 1(已接单 / 待起运)
|
row.setOrderStatus(StringUtils.defaultIfBlank(dto.getOrderStatus(), "1"));
|
||||||
String orderStatus = StringUtils.isBlank(dto.getOrderStatus())
|
|
||||||
? "1" : dto.getOrderStatus().trim();
|
|
||||||
row.setOrderStatus(orderStatus);
|
|
||||||
|
|
||||||
row.setVehicleTypeId(dto.getVehicleTypeId());
|
row.setVehicleTypeId(dto.getVehicleTypeId());
|
||||||
row.setVehicleTypeName(dto.getVehicleTypeName());
|
row.setVehicleTypeName(dto.getVehicleTypeName());
|
||||||
@@ -283,9 +255,10 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
row.setTotalKm(dto.getTotalKm());
|
row.setTotalKm(dto.getTotalKm());
|
||||||
row.setRemark(dto.getRemark());
|
row.setRemark(dto.getRemark());
|
||||||
|
|
||||||
// 2.2 明细字段
|
// 🔥 关键改造点
|
||||||
row.setRkInfoId(it.getRkInfoId()); // 关联 rk_info 主键ID(手动单可以为空)
|
row.setRkRecordId(it.getRkRecordId());
|
||||||
row.setBillNoCk(it.getBillNoCk());
|
row.setBillNo(it.getBillNo());
|
||||||
|
|
||||||
row.setXmMs(it.getXmMs());
|
row.setXmMs(it.getXmMs());
|
||||||
row.setXmNo(it.getXmNo());
|
row.setXmNo(it.getXmNo());
|
||||||
row.setWlNo(it.getWlNo());
|
row.setWlNo(it.getWlNo());
|
||||||
@@ -295,7 +268,6 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
row.setSapNo(it.getSapNo());
|
row.setSapNo(it.getSapNo());
|
||||||
row.setGysMc(it.getGysMc());
|
row.setGysMc(it.getGysMc());
|
||||||
|
|
||||||
// 2.3 通用字段
|
|
||||||
row.setIsDelete("0");
|
row.setIsDelete("0");
|
||||||
row.setCreateTime(now);
|
row.setCreateTime(now);
|
||||||
row.setCreateBy(username);
|
row.setCreateBy(username);
|
||||||
@@ -303,19 +275,14 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
rows.add(row);
|
rows.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 3. 批量落库 ==========
|
|
||||||
|
|
||||||
if (!rows.isEmpty()) {
|
if (!rows.isEmpty()) {
|
||||||
deliveryOrderMapper.batchInsert(rows);
|
deliveryOrderMapper.batchInsert(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 4. 回写 WMS(仅出库单生成场景,手动创建不回写、不远程调用) ==========
|
|
||||||
|
|
||||||
if (fromWms) {
|
if (fromWms) {
|
||||||
boolean ok = updateWmsIsDeliveryByIds(rkInfoIds, 2);
|
boolean ok = updateWmsIsDeliveryByIds(rkRecordIds, 2);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// 回写失败,整单回滚,避免脏数据
|
throw new ServiceException("回写WMS失败");
|
||||||
throw new ServiceException("已生成配送单,但回写 WMS 配送状态失败");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,12 +296,12 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
* POST ${delivery.wisdom-base-url}/wisdom/stock/updateDeliveryStatus
|
* POST ${delivery.wisdom-base-url}/wisdom/stock/updateDeliveryStatus
|
||||||
* Body: { "ids": [1, 2, 3], "isDelivery": 2 }
|
* Body: { "ids": [1, 2, 3], "isDelivery": 2 }
|
||||||
*/
|
*/
|
||||||
private boolean updateWmsIsDeliveryByIds(List<Long> rkInfoIds, int isDelivery) {
|
private boolean updateWmsIsDeliveryByIds(List<Long> rkRecordIds, int isDelivery) {
|
||||||
|
|
||||||
String url = wisdomBaseUrl + "/wisdom/stock/updateDeliveryStatus";
|
String url = wisdomBaseUrl + "/wisdom/record/updateDeliveryStatus";
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("ids", rkInfoIds);
|
map.put("ids", rkRecordIds);
|
||||||
map.put("isDelivery", isDelivery);
|
map.put("isDelivery", isDelivery);
|
||||||
|
|
||||||
String json = JSON.toJSONString(map);
|
String json = JSON.toJSONString(map);
|
||||||
@@ -354,7 +321,7 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("WMS 调用异常 rkInfoIds={} error={}", rkInfoIds, e.getMessage(), e);
|
log.error("WMS 调用异常 rkInfoIds={} error={}", rkRecordIds, e.getMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<!-- 单号 -->
|
<!-- 单号 -->
|
||||||
<result property="orderNo" column="order_no"/>
|
<result property="orderNo" column="order_no"/>
|
||||||
<result property="billNoCk" column="bill_no_ck"/>
|
<result property="billNo" column="bill_no"/>
|
||||||
|
|
||||||
<!-- 新增:rk_info 主键ID -->
|
<!-- 新增:rk_info 主键ID -->
|
||||||
<result property="rkInfoId" column="rk_info_id"/>
|
<result property="rkRecordId" column="rk_record_id"/>
|
||||||
|
|
||||||
<!-- 新增:制单人ID、接收物资状态、问题描述 -->
|
<!-- 新增:制单人ID、接收物资状态、问题描述 -->
|
||||||
<result property="makerId" column="maker_id"/>
|
<result property="makerId" column="maker_id"/>
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
<result property="makerId" column="maker_id"/>
|
<result property="makerId" column="maker_id"/>
|
||||||
<result property="receiveStatus" column="receive_status"/>
|
<result property="receiveStatus" column="receive_status"/>
|
||||||
<result property="receiveProblem" column="receive_problem"/>
|
<result property="receiveProblem" column="receive_problem"/>
|
||||||
<result property="billNoCk" column="bill_no_ck"/>
|
<result property="billNo" column="bill_no"/>
|
||||||
<result property="originName" column="origin_name"/>
|
<result property="originName" column="origin_name"/>
|
||||||
<result property="originLng" column="origin_lng" jdbcType="DECIMAL"/>
|
<result property="originLng" column="origin_lng" jdbcType="DECIMAL"/>
|
||||||
<result property="originLat" column="origin_lat" jdbcType="DECIMAL"/>
|
<result property="originLat" column="origin_lat" jdbcType="DECIMAL"/>
|
||||||
@@ -164,8 +164,8 @@
|
|||||||
select
|
select
|
||||||
dor.id,
|
dor.id,
|
||||||
dor.order_no,
|
dor.order_no,
|
||||||
dor.bill_no_ck,
|
dor.bill_no,
|
||||||
dor.rk_info_id,
|
dor.rk_record_id,
|
||||||
dor.maker_id,
|
dor.maker_id,
|
||||||
-- 制单人用户名(连表 sys_user)
|
-- 制单人用户名(连表 sys_user)
|
||||||
su.user_name AS maker_user_name,
|
su.user_name AS maker_user_name,
|
||||||
@@ -206,7 +206,6 @@
|
|||||||
left join delivery_attachment da
|
left join delivery_attachment da
|
||||||
on da.order_no = dor.order_no
|
on da.order_no = dor.order_no
|
||||||
and da.is_delete = '0'
|
and da.is_delete = '0'
|
||||||
<!-- 报表/列表查询连表 sys_user,按制单人ID 取用户名 -->
|
|
||||||
left join sys_user su
|
left join sys_user su
|
||||||
on su.user_id = dor.maker_id
|
on su.user_id = dor.maker_id
|
||||||
</sql>
|
</sql>
|
||||||
@@ -216,8 +215,8 @@
|
|||||||
select
|
select
|
||||||
id,
|
id,
|
||||||
order_no,
|
order_no,
|
||||||
bill_no_ck,
|
bill_no,
|
||||||
rk_info_id,
|
rk_record_id,
|
||||||
maker_id,
|
maker_id,
|
||||||
receive_status,
|
receive_status,
|
||||||
receive_problem,
|
receive_problem,
|
||||||
@@ -237,6 +236,7 @@
|
|||||||
from delivery_order
|
from delivery_order
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<!-- 仅用于列表:只查配送单据头字段,不查货物明细 -->
|
<!-- 仅用于列表:只查配送单据头字段,不查货物明细 -->
|
||||||
<sql id="selectDeliveryOrderHeader">
|
<sql id="selectDeliveryOrderHeader">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -296,8 +296,8 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
dor.order_no AS order_no,
|
dor.order_no AS order_no,
|
||||||
MAX(dor.bill_no_ck) AS bill_no_ck,
|
MAX(dor.bill_no) AS bill_no,
|
||||||
MAX(dor.rk_info_id) AS rk_info_id,
|
MAX(dor.rk_record_id) AS rk_record_id,
|
||||||
MAX(dor.maker_id) AS maker_id,
|
MAX(dor.maker_id) AS maker_id,
|
||||||
MAX(dor.receive_status) AS receive_status,
|
MAX(dor.receive_status) AS receive_status,
|
||||||
MAX(dor.receive_problem) AS receive_problem,
|
MAX(dor.receive_problem) AS receive_problem,
|
||||||
@@ -324,84 +324,72 @@
|
|||||||
MAX(dor.toll_fee) AS toll_fee,
|
MAX(dor.toll_fee) AS toll_fee,
|
||||||
MAX(dor.total_km) AS total_km,
|
MAX(dor.total_km) AS total_km,
|
||||||
MAX(dor.remark) AS remark
|
MAX(dor.remark) AS remark
|
||||||
|
|
||||||
FROM delivery_order dor
|
FROM delivery_order dor
|
||||||
|
|
||||||
<where>
|
<where>
|
||||||
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
||||||
|
|
||||||
<!-- 单号 -->
|
|
||||||
<if test="orderNo != null and orderNo != ''">
|
<if test="orderNo != null and orderNo != ''">
|
||||||
AND dor.order_no = #{orderNo}
|
AND dor.order_no = #{orderNo}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 出库单据号 -->
|
<if test="billNo != null and billNo != ''">
|
||||||
<if test="billNoCk != null and billNoCk != ''">
|
AND dor.bill_no = #{billNo}
|
||||||
AND dor.bill_no_ck = #{billNoCk}
|
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 制单人 -->
|
|
||||||
<if test="makerId != null">
|
<if test="makerId != null">
|
||||||
AND dor.maker_id = #{makerId}
|
AND dor.maker_id = #{makerId}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 接收物资状态 -->
|
|
||||||
<if test="receiveStatus != null">
|
<if test="receiveStatus != null">
|
||||||
AND dor.receive_status = #{receiveStatus}
|
AND dor.receive_status = #{receiveStatus}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 项目描述(模糊) -->
|
|
||||||
<if test="xmMs != null and xmMs != ''">
|
<if test="xmMs != null and xmMs != ''">
|
||||||
AND dor.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
|
AND dor.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 项目号 -->
|
|
||||||
<if test="xmNo != null and xmNo != ''">
|
<if test="xmNo != null and xmNo != ''">
|
||||||
AND dor.xm_no LIKE CONCAT('%', #{xmNo}, '%')
|
AND dor.xm_no LIKE CONCAT('%', #{xmNo}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 物料号 -->
|
|
||||||
<if test="wlNo != null and wlNo != ''">
|
<if test="wlNo != null and wlNo != ''">
|
||||||
AND dor.wl_no LIKE CONCAT('%', #{wlNo}, '%')
|
AND dor.wl_no LIKE CONCAT('%', #{wlNo}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 物料描述 -->
|
|
||||||
<if test="wlMs != null and wlMs != ''">
|
<if test="wlMs != null and wlMs != ''">
|
||||||
AND dor.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
|
AND dor.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- SAP订单编号 -->
|
|
||||||
<if test="sapNo != null and sapNo != ''">
|
<if test="sapNo != null and sapNo != ''">
|
||||||
AND dor.sap_no LIKE CONCAT('%', #{sapNo}, '%')
|
AND dor.sap_no LIKE CONCAT('%', #{sapNo}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 供应商名称 -->
|
|
||||||
<if test="gysMc != null and gysMc != ''">
|
<if test="gysMc != null and gysMc != ''">
|
||||||
AND dor.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
|
AND dor.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 起始 / 目的地点模糊 -->
|
|
||||||
<if test="originName != null and originName != ''">
|
<if test="originName != null and originName != ''">
|
||||||
AND dor.origin_name LIKE CONCAT('%', #{originName}, '%')
|
AND dor.origin_name LIKE CONCAT('%', #{originName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="destName != null and destName != ''">
|
<if test="destName != null and destName != ''">
|
||||||
AND dor.dest_name LIKE CONCAT('%', #{destName}, '%')
|
AND dor.dest_name LIKE CONCAT('%', #{destName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 配送日期 -->
|
|
||||||
<if test="deliveryDate != null">
|
<if test="deliveryDate != null">
|
||||||
AND dor.delivery_date = #{deliveryDate}
|
AND dor.delivery_date = #{deliveryDate}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- 车牌 -->
|
|
||||||
<if test="plateNo != null and plateNo != ''">
|
<if test="plateNo != null and plateNo != ''">
|
||||||
AND dor.plate_no = #{plateNo}
|
AND dor.plate_no = #{plateNo}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- ✅ 新增/确认:接收单位名称(模糊) -->
|
|
||||||
<if test="receiverOrgName != null and receiverOrgName != ''">
|
<if test="receiverOrgName != null and receiverOrgName != ''">
|
||||||
AND dor.receiver_org_name LIKE CONCAT('%', #{receiverOrgName}, '%')
|
AND dor.receiver_org_name LIKE CONCAT('%', #{receiverOrgName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- ✅ 新增/确认:配送状态(多选优先) -->
|
|
||||||
<if test="orderStatusList != null and orderStatusList.size > 0">
|
<if test="orderStatusList != null and orderStatusList.size > 0">
|
||||||
AND dor.order_status IN
|
AND dor.order_status IN
|
||||||
<foreach collection="orderStatusList" item="st" open="(" separator="," close=")">
|
<foreach collection="orderStatusList" item="st" open="(" separator="," close=")">
|
||||||
@@ -409,25 +397,27 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- ✅ 新增/确认:配送状态(单选兜底) -->
|
|
||||||
<if test="(orderStatusList == null or orderStatusList.size == 0)
|
<if test="(orderStatusList == null or orderStatusList.size == 0)
|
||||||
and orderStatus != null and orderStatus != ''">
|
and orderStatus != null and orderStatus != ''">
|
||||||
AND dor.order_status = #{orderStatus}
|
AND dor.order_status = #{orderStatus}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
GROUP BY dor.order_no
|
GROUP BY dor.order_no
|
||||||
ORDER BY MAX(dor.create_time) DESC
|
ORDER BY MAX(dor.create_time) DESC
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 供 VO 使用:按单号查所有行明细 -->
|
<!-- 供 VO 使用:按单号查所有行明细 -->
|
||||||
<select id="selectLinesByOrderNo"
|
<select id="selectLinesByOrderNo"
|
||||||
parameterType="java.lang.String"
|
parameterType="java.lang.String"
|
||||||
resultType="com.delivery.project.document.domain.dto.DeliveryOrderLineDTO">
|
resultType="com.delivery.project.document.domain.dto.DeliveryOrderLineDTO">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
dor.id,
|
dor.id,
|
||||||
dor.rk_info_id AS rkInfoId,
|
dor.rk_record_id AS rkRecordId,
|
||||||
dor.bill_no_ck AS billNoCk,
|
dor.bill_no AS billNo,
|
||||||
dor.xm_ms AS xmMs,
|
dor.xm_ms AS xmMs,
|
||||||
dor.xm_no AS xmNo,
|
dor.xm_no AS xmNo,
|
||||||
dor.wl_no AS wlNo,
|
dor.wl_no AS wlNo,
|
||||||
@@ -441,6 +431,7 @@
|
|||||||
WHERE (dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
WHERE (dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
||||||
AND dor.order_no = #{value}
|
AND dor.order_no = #{value}
|
||||||
ORDER BY dor.id ASC
|
ORDER BY dor.id ASC
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 供 VO 使用:按单号查附件 -->
|
<!-- 供 VO 使用:按单号查附件 -->
|
||||||
@@ -584,9 +575,10 @@
|
|||||||
<select id="selectGroupList"
|
<select id="selectGroupList"
|
||||||
parameterType="com.delivery.project.document.domain.DeliveryOrder"
|
parameterType="com.delivery.project.document.domain.DeliveryOrder"
|
||||||
resultType="com.delivery.project.document.domain.vo.DeliveryOrderGroupVO">
|
resultType="com.delivery.project.document.domain.vo.DeliveryOrderGroupVO">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
dor.order_no AS orderNo,
|
dor.order_no AS orderNo,
|
||||||
MAX(dor.bill_no_ck) AS billNoCk,
|
MAX(dor.bill_no) AS billNo,
|
||||||
MIN(dor.delivery_date) AS deliveryDate,
|
MIN(dor.delivery_date) AS deliveryDate,
|
||||||
MAX(dor.origin_name) AS originName,
|
MAX(dor.origin_name) AS originName,
|
||||||
MAX(dor.dest_name) AS destName,
|
MAX(dor.dest_name) AS destName,
|
||||||
@@ -596,7 +588,9 @@
|
|||||||
COUNT(1) AS itemCount,
|
COUNT(1) AS itemCount,
|
||||||
SUM(dor.real_qty) AS totalQty,
|
SUM(dor.real_qty) AS totalQty,
|
||||||
MAX(dor.order_status) AS orderStatus
|
MAX(dor.order_status) AS orderStatus
|
||||||
|
|
||||||
FROM delivery_order dor
|
FROM delivery_order dor
|
||||||
|
|
||||||
<where>
|
<where>
|
||||||
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
|
||||||
|
|
||||||
@@ -617,14 +611,19 @@
|
|||||||
<if test="plateNo != null and plateNo != ''">
|
<if test="plateNo != null and plateNo != ''">
|
||||||
AND dor.plate_no = #{plateNo}
|
AND dor.plate_no = #{plateNo}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="deliveryDate != null">
|
<if test="deliveryDate != null">
|
||||||
AND DATE(dor.delivery_date) = DATE(#{deliveryDate})
|
AND DATE(dor.delivery_date) = DATE(#{deliveryDate})
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
GROUP BY dor.order_no
|
GROUP BY dor.order_no
|
||||||
ORDER BY MAX(dor.create_time) DESC
|
ORDER BY MAX(dor.create_time) DESC
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 详情:同单号所有行(带附件 + makerUserName) -->
|
<!-- 详情:同单号所有行(带附件 + makerUserName) -->
|
||||||
<select id="selectByOrderNo"
|
<select id="selectByOrderNo"
|
||||||
parameterType="string"
|
parameterType="string"
|
||||||
@@ -646,17 +645,16 @@
|
|||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- ======================== 插入 ======================== -->
|
|
||||||
|
|
||||||
<!-- 单条插入 -->
|
<!-- 单条插入 -->
|
||||||
<insert id="insertDeliveryOrder"
|
<insert id="insertDeliveryOrder"
|
||||||
parameterType="com.delivery.project.document.domain.DeliveryOrder"
|
parameterType="com.delivery.project.document.domain.DeliveryOrder"
|
||||||
useGeneratedKeys="true" keyProperty="id">
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|
||||||
insert into delivery_order
|
insert into delivery_order
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderNo != null">order_no,</if>
|
<if test="orderNo != null">order_no,</if>
|
||||||
<if test="billNoCk != null">bill_no_ck,</if>
|
<if test="billNo != null">bill_no,</if>
|
||||||
<if test="rkInfoId != null">rk_info_id,</if>
|
<if test="rkRecordId != null">rk_record_id,</if>
|
||||||
<if test="makerId != null">maker_id,</if>
|
<if test="makerId != null">maker_id,</if>
|
||||||
<if test="receiveStatus != null">receive_status,</if>
|
<if test="receiveStatus != null">receive_status,</if>
|
||||||
<if test="receiveProblem != null">receive_problem,</if>
|
<if test="receiveProblem != null">receive_problem,</if>
|
||||||
@@ -670,6 +668,7 @@
|
|||||||
<if test="sapNo != null">sap_no,</if>
|
<if test="sapNo != null">sap_no,</if>
|
||||||
<if test="gysMc != null">gys_mc,</if>
|
<if test="gysMc != null">gys_mc,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
|
|
||||||
<if test="originName != null">origin_name,</if>
|
<if test="originName != null">origin_name,</if>
|
||||||
<if test="originLng != null">origin_lng,</if>
|
<if test="originLng != null">origin_lng,</if>
|
||||||
<if test="originLat != null">origin_lat,</if>
|
<if test="originLat != null">origin_lat,</if>
|
||||||
@@ -687,6 +686,7 @@
|
|||||||
<if test="receiverName != null">receiver_name,</if>
|
<if test="receiverName != null">receiver_name,</if>
|
||||||
<if test="receiverPhone != null">receiver_phone,</if>
|
<if test="receiverPhone != null">receiver_phone,</if>
|
||||||
<if test="receiverOrgName != null">receiver_org_name,</if>
|
<if test="receiverOrgName != null">receiver_org_name,</if>
|
||||||
|
|
||||||
<if test="deliveryTon != null">delivery_ton,</if>
|
<if test="deliveryTon != null">delivery_ton,</if>
|
||||||
<if test="goodsSize != null">goods_size,</if>
|
<if test="goodsSize != null">goods_size,</if>
|
||||||
<if test="orderStatus != null">order_status,</if>
|
<if test="orderStatus != null">order_status,</if>
|
||||||
@@ -705,10 +705,11 @@
|
|||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="isDelete != null">is_delete,</if>
|
<if test="isDelete != null">is_delete,</if>
|
||||||
</trim>
|
</trim>
|
||||||
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
|
<if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
|
||||||
<if test="billNoCk != null">#{billNoCk},</if>
|
<if test="billNo != null">#{billNo,jdbcType=VARCHAR},</if>
|
||||||
<if test="rkInfoId != null">#{rkInfoId},</if>
|
<if test="rkRecordId != null">#{rkRecordId},</if>
|
||||||
<if test="makerId != null">#{makerId},</if>
|
<if test="makerId != null">#{makerId},</if>
|
||||||
<if test="receiveStatus != null">#{receiveStatus},</if>
|
<if test="receiveStatus != null">#{receiveStatus},</if>
|
||||||
<if test="receiveProblem != null">#{receiveProblem},</if>
|
<if test="receiveProblem != null">#{receiveProblem},</if>
|
||||||
@@ -722,6 +723,7 @@
|
|||||||
<if test="sapNo != null">#{sapNo},</if>
|
<if test="sapNo != null">#{sapNo},</if>
|
||||||
<if test="gysMc != null">#{gysMc},</if>
|
<if test="gysMc != null">#{gysMc},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
|
|
||||||
<if test="originName != null">#{originName},</if>
|
<if test="originName != null">#{originName},</if>
|
||||||
<if test="originLng != null">#{originLng},</if>
|
<if test="originLng != null">#{originLng},</if>
|
||||||
<if test="originLat != null">#{originLat},</if>
|
<if test="originLat != null">#{originLat},</if>
|
||||||
@@ -739,6 +741,7 @@
|
|||||||
<if test="receiverName != null">#{receiverName},</if>
|
<if test="receiverName != null">#{receiverName},</if>
|
||||||
<if test="receiverPhone != null">#{receiverPhone},</if>
|
<if test="receiverPhone != null">#{receiverPhone},</if>
|
||||||
<if test="receiverOrgName != null">#{receiverOrgName},</if>
|
<if test="receiverOrgName != null">#{receiverOrgName},</if>
|
||||||
|
|
||||||
<if test="deliveryTon != null">#{deliveryTon},</if>
|
<if test="deliveryTon != null">#{deliveryTon},</if>
|
||||||
<if test="goodsSize != null">#{goodsSize},</if>
|
<if test="goodsSize != null">#{goodsSize},</if>
|
||||||
<if test="orderStatus != null">#{orderStatus},</if>
|
<if test="orderStatus != null">#{orderStatus},</if>
|
||||||
@@ -757,12 +760,13 @@
|
|||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
<if test="isDelete != null">#{isDelete},</if>
|
<if test="isDelete != null">#{isDelete},</if>
|
||||||
</trim>
|
</trim>
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 批量插入 -->
|
<!-- 批量插入 -->
|
||||||
<insert id="batchInsert" parameterType="java.util.List">
|
<insert id="batchInsert" parameterType="java.util.List">
|
||||||
INSERT INTO delivery_order
|
INSERT INTO delivery_order
|
||||||
(order_no, bill_no_ck, rk_info_id, maker_id, receive_status, receive_problem,
|
(order_no, bill_no, rk_record_id, maker_id, receive_status, receive_problem,
|
||||||
xm_ms, xm_no, wl_no, wl_ms, real_qty, dw, sap_no, gys_mc, remark,
|
xm_ms, xm_no, wl_no, wl_ms, real_qty, dw, sap_no, gys_mc, remark,
|
||||||
origin_name, origin_lng, origin_lat,
|
origin_name, origin_lng, origin_lat,
|
||||||
dest_name, dest_lng, dest_lat,
|
dest_name, dest_lng, dest_lat,
|
||||||
@@ -777,27 +781,59 @@
|
|||||||
<foreach collection="list" item="it" separator=",">
|
<foreach collection="list" item="it" separator=",">
|
||||||
(
|
(
|
||||||
#{it.orderNo},
|
#{it.orderNo},
|
||||||
#{it.billNoCk},
|
#{it.billNo},
|
||||||
#{it.rkInfoId},
|
#{it.rkRecordId},
|
||||||
#{it.makerId},
|
#{it.makerId},
|
||||||
#{it.receiveStatus},
|
#{it.receiveStatus},
|
||||||
#{it.receiveProblem},
|
#{it.receiveProblem},
|
||||||
|
|
||||||
#{it.xmMs}, #{it.xmNo}, #{it.wlNo}, #{it.wlMs}, #{it.realQty}, #{it.dw},
|
#{it.xmMs},
|
||||||
#{it.sapNo}, #{it.gysMc}, #{it.remark},
|
#{it.xmNo},
|
||||||
|
#{it.wlNo},
|
||||||
|
#{it.wlMs},
|
||||||
|
#{it.realQty},
|
||||||
|
#{it.dw},
|
||||||
|
#{it.sapNo},
|
||||||
|
#{it.gysMc},
|
||||||
|
#{it.remark},
|
||||||
|
|
||||||
#{it.originName}, #{it.originLng}, #{it.originLat},
|
#{it.originName},
|
||||||
#{it.destName}, #{it.destLng}, #{it.destLat},
|
#{it.originLng},
|
||||||
|
#{it.originLat},
|
||||||
|
|
||||||
#{it.deliveryDate}, #{it.plateNo},
|
#{it.destName},
|
||||||
#{it.driverName}, #{it.driverPhone},
|
#{it.destLng},
|
||||||
#{it.shipperName}, #{it.shipperPhone}, #{it.receiverName}, #{it.receiverPhone}, #{it.receiverOrgName},
|
#{it.destLat},
|
||||||
|
|
||||||
#{it.deliveryTon}, #{it.goodsSize}, #{it.orderStatus},
|
#{it.deliveryDate},
|
||||||
#{it.vehicleTypeId}, #{it.vehicleTypeName},
|
#{it.plateNo},
|
||||||
|
|
||||||
#{it.suggestFee}, #{it.actualFee}, #{it.tollFee}, #{it.totalKm},
|
#{it.driverName},
|
||||||
#{it.createBy}, #{it.createTime}, #{it.updateBy}, #{it.updateTime}, #{it.isDelete}
|
#{it.driverPhone},
|
||||||
|
|
||||||
|
#{it.shipperName},
|
||||||
|
#{it.shipperPhone},
|
||||||
|
#{it.receiverName},
|
||||||
|
#{it.receiverPhone},
|
||||||
|
#{it.receiverOrgName},
|
||||||
|
|
||||||
|
#{it.deliveryTon},
|
||||||
|
#{it.goodsSize},
|
||||||
|
#{it.orderStatus},
|
||||||
|
|
||||||
|
#{it.vehicleTypeId},
|
||||||
|
#{it.vehicleTypeName},
|
||||||
|
|
||||||
|
#{it.suggestFee},
|
||||||
|
#{it.actualFee},
|
||||||
|
#{it.tollFee},
|
||||||
|
#{it.totalKm},
|
||||||
|
|
||||||
|
#{it.createBy},
|
||||||
|
#{it.createTime},
|
||||||
|
#{it.updateBy},
|
||||||
|
#{it.updateTime},
|
||||||
|
#{it.isDelete}
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
@@ -805,10 +841,12 @@
|
|||||||
<!-- ======================== 更新 ======================== -->
|
<!-- ======================== 更新 ======================== -->
|
||||||
<update id="updateDeliveryOrder"
|
<update id="updateDeliveryOrder"
|
||||||
parameterType="com.delivery.project.document.domain.DeliveryOrder">
|
parameterType="com.delivery.project.document.domain.DeliveryOrder">
|
||||||
|
|
||||||
UPDATE delivery_order
|
UPDATE delivery_order
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="billNoCk != null">bill_no_ck = #{billNoCk},</if>
|
|
||||||
<if test="rkInfoId != null">rk_info_id = #{rkInfoId},</if>
|
<if test="billNo != null">bill_no = #{billNo},</if>
|
||||||
|
<if test="rkRecordId != null">rk_record_id = #{rkRecordId},</if>
|
||||||
<if test="makerId != null">maker_id = #{makerId},</if>
|
<if test="makerId != null">maker_id = #{makerId},</if>
|
||||||
<if test="receiveStatus != null">receive_status = #{receiveStatus},</if>
|
<if test="receiveStatus != null">receive_status = #{receiveStatus},</if>
|
||||||
<if test="receiveProblem != null">receive_problem = #{receiveProblem},</if>
|
<if test="receiveProblem != null">receive_problem = #{receiveProblem},</if>
|
||||||
@@ -858,10 +896,14 @@
|
|||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="isDelete != null">is_delete = #{isDelete},</if>
|
<if test="isDelete != null">is_delete = #{isDelete},</if>
|
||||||
|
|
||||||
</trim>
|
</trim>
|
||||||
|
|
||||||
WHERE order_no = #{orderNo}
|
WHERE order_no = #{orderNo}
|
||||||
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<!-- ======================== 删除 ======================== -->
|
<!-- ======================== 删除 ======================== -->
|
||||||
<delete id="deleteDeliveryOrderById" parameterType="java.lang.Long">
|
<delete id="deleteDeliveryOrderById" parameterType="java.lang.Long">
|
||||||
delete from delivery_order where id = #{id}
|
delete from delivery_order where id = #{id}
|
||||||
|
|||||||
Reference in New Issue
Block a user