OMS调整接口开发
This commit is contained in:
+554
@@ -0,0 +1,554 @@
|
||||
package com.mhd.oms.application.service.businessDocumentOrder;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.repository.mapper.BusinessDocumentOrderAdjustMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.repository.mapper.BusinessDocumentOrderAdjustDetailMapper;
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import com.mhd.oms.domain.businessOrderAccount.repository.mapper.BusinessOrderAccountMapper;
|
||||
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
|
||||
import com.mhd.oms.domain.executeOrder.repository.mapper.ExecuteOrderMapper;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
||||
import com.mhd.system.api.WlhyServiceFeign;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 运输业务单「订单调整」应用服务
|
||||
*
|
||||
* 规则(定稿):
|
||||
* 1. 每次调整都生成:1 条主记录 + 1 条明细快照
|
||||
* 2. 费用数据源 = 前端回传的费用明细 business_order_account(feeDetailList);
|
||||
* 主表金额 deliveryFreight 为其 amount 合计(冗余汇总,后端自动算)。
|
||||
* 3. 是否需审核:一旦任一「金额」发生变化
|
||||
* = feeDetailList 明细 amount 变化,或主表金额列变化 -> 走业务主管审核;
|
||||
* 否则(仅改非金额字段) -> 直通。
|
||||
* 4. 涉及金额提交 -> 仅把业务单 review_status 置为「调整待审核(3)」;主记录 AUDIT_STATUS=0(待审核);
|
||||
* 不更新业务单数据,不影响其它状态(order_status / execute_status 不动)。
|
||||
* 5. 审核通过 -> 覆盖业务单(金额) + 替换费用明细;review_status 一律置为 1(已审核),
|
||||
* 不影响 order_status / execute_status。
|
||||
* 审核驳回 -> 不更新业务单数据,review_status 还原为调整前值(主记录 before_review_status),可再次调整。
|
||||
* 6. 直通(未改金额) -> 覆盖业务单可编辑字段 + deliveryFreight(明细合计),并替换 business_order_account
|
||||
* (逻辑删旧 is_delete=1 + 插新 is_delete=0);不改动任何审核/执行状态。
|
||||
* 7. 前端以 amountChanged 告知是否改金额(默认前端判定);未传时后端兜底比对。
|
||||
*
|
||||
* 说明:review_status 原枚举 0未审/1通过/2驳回,新增 3=调整待审核;不改变原有用例。
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessDocumentOrderAdjustService {
|
||||
|
||||
private static final Integer AUDIT_WAIT = 0; // 调整记录:待审核
|
||||
private static final Integer AUDIT_PASS = 1; // 调整记录:审核通过
|
||||
private static final Integer AUDIT_REJECT = 2; // 调整记录:驳回
|
||||
|
||||
/** 主表金额(费用)字段,任一变化触发审核 */
|
||||
private static final List<String> FEE_FIELDS = Arrays.asList(
|
||||
"deliveryFreight", "collectedFreight", "uncollectedFreight", "collectLessFreight",
|
||||
"transportationUnitPrice", "infoFee", "freightUnitPrice", "cargoInsuranceAmount",
|
||||
"freightCharges", "freightFee", "unloadingFee", "customsFee", "shortageFee",
|
||||
"miscellaneousFee", "otherFee", "detentionFee");
|
||||
|
||||
/** 不允许被前端调整覆盖的系统字段 */
|
||||
private static final List<String> PROTECTED_FIELDS = Arrays.asList(
|
||||
"id", "goodsNumber",
|
||||
"orderStatus", "reviewStatus", "reviewId", "review", "reviewTime", "reviewOpinion",
|
||||
"salesManager", "auditStatus", "auditBy", "auditTime",
|
||||
"executeStatus", "executeId", "executeTime", "executor",
|
||||
"executeOrderId", "executeOrderNumber", "adjustStatus",
|
||||
"isDelete", "delFlag", "createBy", "createByName", "createTime",
|
||||
"updateBy", "updateByName", "updateTime",
|
||||
"pushStatus", "pushTime", "pushBy", "pushByName",
|
||||
"reviseApplyType", "reviseApplyStatus", "reviseApplyBy", "reviseApplyByName",
|
||||
"reviseApplyReason", "reviseApplyTime",
|
||||
"reservationOrderId", "reservationOrderNumber",
|
||||
"mainOrderId", "mainOrderNum", "mergeOrderId", "mergeOrderNum",
|
||||
"splicingOrderType", "splicingStatus", "deliveryProgress",
|
||||
"orgId", "orgName", "organizationId", "organizationName", "topOrganizationId",
|
||||
"realCreateBy", "realCreateName", "createCompanyId", "createUserId",
|
||||
"szwlUserId"
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderMapper businessDocumentOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessOrderAccountMapper businessOrderAccountMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderAdjustMapper adjustMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderAdjustDetailMapper adjustDetailMapper;
|
||||
|
||||
@Autowired
|
||||
private ExecuteOrderMapper executeOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private WlhyServiceFeign wlhyServiceFeign;
|
||||
|
||||
/**
|
||||
* 提交调整
|
||||
* 返回 data = [是否需审核, 调整记录ID]
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult adjust(BusinessDocumentOrderAdjustDTO dto) {
|
||||
if (dto == null || dto.getOrder() == null || dto.getOrder().getId() == null) {
|
||||
throw new ServiceException("参数错误:缺少业务单ID(order.id)");
|
||||
}
|
||||
BusinessDocumentOrder dbOrder = businessDocumentOrderMapper.selectById(dto.getOrder().getId());
|
||||
if (ObjectUtil.isNull(dbOrder)) {
|
||||
throw new ServiceException("业务单不存在或已被删除");
|
||||
}
|
||||
BusinessDocumentOrder front = dto.getOrder();
|
||||
|
||||
// 1. 当前库中费用明细
|
||||
List<BusinessOrderAccount> dbFeeList = businessOrderAccountMapper.selectList(
|
||||
new LambdaQueryWrapper<BusinessOrderAccount>()
|
||||
.eq(BusinessOrderAccount::getOrderId, dbOrder.getId())
|
||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
||||
|
||||
// 2. 调整后的费用明细(前端);为 null 则视为保持库中不变
|
||||
List<BusinessOrderAccount> newFeeList = dto.getFeeDetailList();
|
||||
|
||||
// 3. 生成"调整后"业务单对象:DB原值 + 前端可编辑字段覆盖(忽略null)
|
||||
BusinessDocumentOrder afterOrder = buildAfterOrder(dbOrder, front);
|
||||
|
||||
// 4. 若提供了费用明细,则 deliveryFreight(合计)=明细 amount 之和,并联动到 afterOrder
|
||||
boolean hasFeeDetail = newFeeList != null && !newFeeList.isEmpty();
|
||||
if (hasFeeDetail) {
|
||||
BigDecimal sum = sumAmount(newFeeList);
|
||||
afterOrder.setDeliveryFreight(sum);
|
||||
}
|
||||
|
||||
// 5. 判定是否修改了金额:以前端 amountChanged 为准(前端整单回传已自行判定);
|
||||
// 若前端未传则后端兜底比对(主表金额列 或 明细 amount 变化)
|
||||
boolean amountChanged;
|
||||
if (dto.getAmountChanged() != null) {
|
||||
amountChanged = dto.getAmountChanged();
|
||||
} else {
|
||||
amountChanged = isAmountChanged(dbOrder, front, hasFeeDetail, dbFeeList, newFeeList);
|
||||
}
|
||||
|
||||
// 6. 写主记录
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Date now = new Date();
|
||||
BusinessDocumentOrderAdjust adjust = buildAdjust(dbOrder, loginUser, now, amountChanged, dto.getAdjustReason());
|
||||
adjustMapper.insert(adjust);
|
||||
|
||||
// 7. 写明细快照(调整后业务单整行 + 费用明细JSON)
|
||||
BusinessDocumentOrderAdjustDetail detail = new BusinessDocumentOrderAdjustDetail();
|
||||
copySnapshot(afterOrder, detail);
|
||||
if (hasFeeDetail) {
|
||||
detail.setFeeDetailJson(JSONUtil.toJsonStr(newFeeList));
|
||||
}
|
||||
detail.setAdjustId(adjust.getId());
|
||||
detail.setOrderId(dbOrder.getId());
|
||||
detail.setGoodsNumber(dbOrder.getGoodsNumber());
|
||||
detail.setCreateBy(adjust.getAdjustBy());
|
||||
detail.setCreateName(adjust.getAdjustByName());
|
||||
detail.setCreateTime(now);
|
||||
detail.setDelFlag(1);
|
||||
adjustDetailMapper.insert(detail);
|
||||
|
||||
if (!amountChanged) {
|
||||
// 8a. 直通:覆盖主表可编辑字段(含 deliveryFreight 合计) + 替换费用明细;不改动任何审核/执行状态
|
||||
saveOrderAndFee(dbOrder.getId(), afterOrder, hasFeeDetail ? newFeeList : dbFeeList, loginUser, now, false, null);
|
||||
updateAdjustPass(adjust.getId(), adjust.getAdjustBy(), adjust.getAdjustByName(), now, null);
|
||||
syncTmsAsync(dbOrder.getGoodsNumber(), afterOrder);
|
||||
} else {
|
||||
// 8b. 涉及金额:仅把业务单 review_status 置为"调整待审核(3)",其余状态(exec/orderStatus)不动,不更新业务单数据
|
||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||
statusOnly.setId(dbOrder.getId());
|
||||
statusOnly.setReviewStatus(3L); // 调整待审核
|
||||
businessDocumentOrderMapper.updateById(statusOnly);
|
||||
}
|
||||
|
||||
return AjaxResult.success(new Object[]{amountChanged, adjust.getId()});
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整记录列表(管理页:查全部,可选按订单/业务单号/审核状态等筛选,配合分页使用)
|
||||
*/
|
||||
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecord(BusinessDocumentOrderAdjustQueryDTO query) {
|
||||
LambdaQueryWrapper<BusinessDocumentOrderAdjust> wrapper = new LambdaQueryWrapper<BusinessDocumentOrderAdjust>()
|
||||
.eq(BusinessDocumentOrderAdjust::getDelFlag, 1);
|
||||
|
||||
// ===== 组织隔离(参考业务单 queryList 口径) =====
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long loginOrgId = loginUser.getUserPo().getOrganizationId();
|
||||
Long loginTopOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||
// 一级组织非1(集团)时,按一级组织过滤(可看本一级组织下所有)
|
||||
if (loginTopOrgId != null && loginTopOrgId != 1) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getTopOrgId, String.valueOf(loginTopOrgId));
|
||||
} else if (loginOrgId != null) {
|
||||
// 否则按当前组织过滤;若查询方显式指定了 organizationId 则以其为准
|
||||
Long effOrgId = (query != null && query.getOrganizationId() != null)
|
||||
? query.getOrganizationId() : loginOrgId;
|
||||
if (effOrgId != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrgId, String.valueOf(effOrgId));
|
||||
}
|
||||
}
|
||||
} else if (query != null && query.getOrganizationId() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrgId, String.valueOf(query.getOrganizationId()));
|
||||
}
|
||||
|
||||
if (query != null) {
|
||||
if (query.getOrderId() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrderId, query.getOrderId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getGoodsNumber())) {
|
||||
wrapper.like(BusinessDocumentOrderAdjust::getGoodsNumber, query.getGoodsNumber());
|
||||
}
|
||||
if (query.getIsAudit() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getIsAudit, query.getIsAudit());
|
||||
}
|
||||
if (query.getAuditStatus() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getAuditStatus, query.getAuditStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getAdjustByName())) {
|
||||
wrapper.like(BusinessDocumentOrderAdjust::getAdjustByName, query.getAdjustByName());
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(BusinessDocumentOrderAdjust::getAdjustTime);
|
||||
List<BusinessDocumentOrderAdjust> list = adjustMapper.selectList(wrapper);
|
||||
return list.stream().map(a -> {
|
||||
BusinessDocumentOrderAdjustRecordDTO vo = new BusinessDocumentOrderAdjustRecordDTO();
|
||||
BeanUtil.copyProperties(a, vo);
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 按业务单查询调整记录(供订单详情页"调整记录"Tab用)
|
||||
*/
|
||||
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecordByOrder(Long orderId) {
|
||||
BusinessDocumentOrderAdjustQueryDTO query = new BusinessDocumentOrderAdjustQueryDTO();
|
||||
query.setOrderId(orderId);
|
||||
return listAdjustRecord(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整记录详情(主记录 + 调整后明细快照)
|
||||
*/
|
||||
public BusinessDocumentOrderAdjustRecordDTO getAdjustRecord(Long adjustId) {
|
||||
BusinessDocumentOrderAdjust adjust = adjustMapper.selectById(adjustId);
|
||||
if (adjust == null) {
|
||||
throw new ServiceException("调整记录不存在");
|
||||
}
|
||||
BusinessDocumentOrderAdjustRecordDTO vo = new BusinessDocumentOrderAdjustRecordDTO();
|
||||
BeanUtil.copyProperties(adjust, vo);
|
||||
BusinessDocumentOrderAdjustDetail detail = adjustDetailMapper.selectOne(
|
||||
new LambdaQueryWrapper<BusinessDocumentOrderAdjustDetail>()
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getAdjustId, adjustId)
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getDelFlag, 1)
|
||||
.last("LIMIT 1"));
|
||||
vo.setDetail(detail);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整审核(通过/驳回),业务主管操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult auditAdjust(BusinessDocumentOrderAdjustAuditDTO auditDTO) {
|
||||
if (auditDTO == null || auditDTO.getAdjustId() == null) {
|
||||
throw new ServiceException("参数错误:缺少调整记录ID");
|
||||
}
|
||||
BusinessDocumentOrderAdjust adjust = adjustMapper.selectById(auditDTO.getAdjustId());
|
||||
if (adjust == null) {
|
||||
throw new ServiceException("调整记录不存在");
|
||||
}
|
||||
if (adjust.getAuditStatus() == null || adjust.getAuditStatus() != AUDIT_WAIT) {
|
||||
throw new ServiceException("该调整记录非待审核状态,无法审核");
|
||||
}
|
||||
Integer result = auditDTO.getAuditResult();
|
||||
if (result == null || (result != AUDIT_PASS && result != AUDIT_REJECT)) {
|
||||
throw new ServiceException("审核结果非法");
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String auditBy = loginUser != null ? String.valueOf(loginUser.getUserid()) : null;
|
||||
String auditByName = loginUser != null && loginUser.getWlhyLoginUser() != null ? loginUser.getWlhyLoginUser().getRealname() : null;
|
||||
Date now = new Date();
|
||||
|
||||
if (result == AUDIT_PASS) {
|
||||
BusinessDocumentOrder order = businessDocumentOrderMapper.selectById(adjust.getOrderId());
|
||||
if (ObjectUtil.isNull(order)) {
|
||||
throw new ServiceException("业务单不存在");
|
||||
}
|
||||
BusinessDocumentOrderAdjustDetail detail = adjustDetailMapper.selectOne(
|
||||
new LambdaQueryWrapper<BusinessDocumentOrderAdjustDetail>()
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getAdjustId, adjust.getId())
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getDelFlag, 1)
|
||||
.last("LIMIT 1"));
|
||||
|
||||
// 还原调整后业务单(从JSON整行快照)
|
||||
BusinessDocumentOrder snapshot = null;
|
||||
if (detail != null && StrUtil.isNotBlank(detail.getOrderSnapshotJson())) {
|
||||
try {
|
||||
snapshot = JSONUtil.toBean(detail.getOrderSnapshotJson(), BusinessDocumentOrder.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析调整快照JSON失败", e);
|
||||
}
|
||||
}
|
||||
BusinessDocumentOrder toSave = new BusinessDocumentOrder();
|
||||
toSave.setId(order.getId());
|
||||
if (snapshot != null) {
|
||||
BeanUtil.copyProperties(snapshot, toSave, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
} else if (detail != null) {
|
||||
BeanUtil.copyProperties(detail, toSave, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
}
|
||||
|
||||
// 还原调整后费用明细(从 feeDetailJson)
|
||||
List<BusinessOrderAccount> newFeeList = new ArrayList<>();
|
||||
if (detail != null && StrUtil.isNotBlank(detail.getFeeDetailJson())) {
|
||||
try {
|
||||
newFeeList = JSONUtil.toList(detail.getFeeDetailJson(), BusinessOrderAccount.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析调整费用明细JSON失败", e);
|
||||
}
|
||||
}
|
||||
// 若快照中有明细合计则保证 deliveryFreight 一致
|
||||
if (!newFeeList.isEmpty()) {
|
||||
toSave.setDeliveryFreight(sumAmount(newFeeList));
|
||||
}
|
||||
// 审核通过后 review_status 一律置为 1(已审核);不影响 order_status / execute_status
|
||||
toSave.setReviewStatus(1L);
|
||||
// 覆盖业务单 + 替换费用明细
|
||||
saveOrderAndFee(order.getId(), toSave, newFeeList, loginUser, now, false, null);
|
||||
|
||||
updateAdjustPass(adjust.getId(), auditBy, auditByName, now, auditDTO.getAuditRemark());
|
||||
syncTmsAsync(order.getGoodsNumber(), toSave);
|
||||
} else {
|
||||
adjust.setAuditStatus(AUDIT_REJECT);
|
||||
adjust.setAuditBy(auditBy);
|
||||
adjust.setAuditByName(auditByName);
|
||||
adjust.setAuditTime(now);
|
||||
adjust.setAuditRemark(auditDTO.getAuditRemark());
|
||||
adjust.setUpdateBy(auditBy);
|
||||
adjust.setUpdateTime(now);
|
||||
adjustMapper.updateById(adjust);
|
||||
|
||||
// 驳回:不更新业务单数据,仅把 review_status 还原为调整前值(不影响其它状态)
|
||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||
statusOnly.setId(adjust.getOrderId());
|
||||
statusOnly.setReviewStatus(adjust.getBeforeReviewStatus() == null ? 0L : adjust.getBeforeReviewStatus());
|
||||
businessDocumentOrderMapper.updateById(statusOnly);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 私有工具
|
||||
// =====================================================
|
||||
|
||||
private BusinessDocumentOrder buildAfterOrder(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front) {
|
||||
BusinessDocumentOrder after = new BusinessDocumentOrder();
|
||||
BeanUtil.copyProperties(dbOrder, after, CopyOptions.create().setIgnoreNullValue(true));
|
||||
BeanUtil.copyProperties(front, after, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
after.setId(dbOrder.getId());
|
||||
return after;
|
||||
}
|
||||
|
||||
private BusinessDocumentOrderAdjust buildAdjust(BusinessDocumentOrder dbOrder, LoginUser u, Date now,
|
||||
boolean amountChanged, String reason) {
|
||||
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
||||
adjust.setOrderId(dbOrder.getId());
|
||||
adjust.setGoodsNumber(dbOrder.getGoodsNumber());
|
||||
adjust.setAdjustBy(u != null ? String.valueOf(u.getUserid()) : null);
|
||||
adjust.setAdjustByName(u != null && u.getWlhyLoginUser() != null ? u.getWlhyLoginUser().getRealname() : null);
|
||||
adjust.setAdjustTime(now);
|
||||
adjust.setAdjustReason(reason);
|
||||
adjust.setIsAudit(amountChanged ? 1 : 0);
|
||||
adjust.setAuditStatus(amountChanged ? AUDIT_WAIT : AUDIT_PASS);
|
||||
adjust.setBeforeReviewStatus(dbOrder.getReviewStatus());
|
||||
// 组织信息:参考业务单口径,取当前登录用户所属组织(调整人归属)
|
||||
if (u != null && u.getUserPo() != null) {
|
||||
if (u.getUserPo().getOrganizationId() != null) {
|
||||
adjust.setOrgId(String.valueOf(u.getUserPo().getOrganizationId()));
|
||||
} else {
|
||||
adjust.setOrgId(dbOrder.getOrgId());
|
||||
}
|
||||
if (u.getUserPo().getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(u.getUserPo().getTopOrganizationId()));
|
||||
} else if (dbOrder.getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(dbOrder.getTopOrganizationId()));
|
||||
}
|
||||
} else {
|
||||
adjust.setOrgId(dbOrder.getOrgId());
|
||||
if (dbOrder.getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(dbOrder.getTopOrganizationId()));
|
||||
}
|
||||
}
|
||||
adjust.setCreateBy(adjust.getAdjustBy());
|
||||
adjust.setCreateName(adjust.getAdjustByName());
|
||||
adjust.setCreateTime(now);
|
||||
adjust.setDelFlag(1);
|
||||
return adjust;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否修改了金额:主表金额列变化 或 明细 amount 变化
|
||||
*/
|
||||
private boolean isAmountChanged(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front,
|
||||
boolean hasFeeDetail, List<BusinessOrderAccount> dbFeeList,
|
||||
List<BusinessOrderAccount> newFeeList) {
|
||||
// a) 主表金额列比对
|
||||
boolean mainChanged = FEE_FIELDS.stream().anyMatch(field -> {
|
||||
Object newVal = BeanUtil.getFieldValue(front, field);
|
||||
if (newVal == null) {
|
||||
return false;
|
||||
}
|
||||
Object oldVal = BeanUtil.getFieldValue(dbOrder, field);
|
||||
BigDecimal old = oldVal == null ? BigDecimal.ZERO : (BigDecimal) oldVal;
|
||||
BigDecimal now = (BigDecimal) newVal;
|
||||
return old.compareTo(now) != 0;
|
||||
});
|
||||
if (mainChanged) {
|
||||
return true;
|
||||
}
|
||||
// b) 若前端未传明细,则只看主表;若传了明细,比较明细金额
|
||||
if (!hasFeeDetail) {
|
||||
return false;
|
||||
}
|
||||
// 明细合计对比
|
||||
BigDecimal oldSum = sumAmount(dbFeeList);
|
||||
BigDecimal newSum = sumAmount(newFeeList);
|
||||
return oldSum.compareTo(newSum) != 0;
|
||||
}
|
||||
|
||||
private BigDecimal sumAmount(List<BusinessOrderAccount> list) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
if (list == null) {
|
||||
return sum;
|
||||
}
|
||||
for (BusinessOrderAccount acc : list) {
|
||||
if (acc.getAmount() != null) {
|
||||
sum = sum.add(acc.getAmount());
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖业务单可编辑字段 + 替换费用明细(逻辑删旧 + 插新)
|
||||
*/
|
||||
/**
|
||||
* 覆盖业务单可编辑字段 + 替换费用明细(逻辑删旧 + 插新)
|
||||
* @param restoreReview 是否还原审核状态(审核通过/驳回后 true;直通 false 不改任何审核状态)
|
||||
* @param beforeReviewStatus 调整前 review_status,用于还原
|
||||
*/
|
||||
private void saveOrderAndFee(Long orderId, BusinessDocumentOrder toSave,
|
||||
List<BusinessOrderAccount> newFeeList,
|
||||
LoginUser loginUser, Date now,
|
||||
boolean restoreReview, Long beforeReviewStatus) {
|
||||
if (restoreReview) {
|
||||
// 仅还原 review_status 到调整前值;不影响 order_status / execute_status 等其它状态
|
||||
toSave.setReviewStatus(beforeReviewStatus == null ? 0L : beforeReviewStatus);
|
||||
}
|
||||
businessDocumentOrderMapper.updateById(toSave);
|
||||
|
||||
// 逻辑删旧明细
|
||||
List<BusinessOrderAccount> oldFeeList = businessOrderAccountMapper.selectList(
|
||||
new LambdaQueryWrapper<BusinessOrderAccount>()
|
||||
.eq(BusinessOrderAccount::getOrderId, orderId)
|
||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
||||
if (oldFeeList != null) {
|
||||
for (BusinessOrderAccount oldAcc : oldFeeList) {
|
||||
oldAcc.setIsDelete(1);
|
||||
oldAcc.setUpdateBy(loginUser != null ? String.valueOf(loginUser.getUserid()) : null);
|
||||
oldAcc.setUpdateTime(now);
|
||||
businessOrderAccountMapper.updateById(oldAcc);
|
||||
}
|
||||
}
|
||||
// 插新明细
|
||||
if (newFeeList != null && !newFeeList.isEmpty()) {
|
||||
for (BusinessOrderAccount acc : newFeeList) {
|
||||
acc.setId(IdUtil.randomUUID());
|
||||
acc.setOrderId(String.valueOf(orderId));
|
||||
acc.setIsDelete(0);
|
||||
acc.setCreateBy(loginUser != null ? String.valueOf(loginUser.getUserid()) : null);
|
||||
acc.setCreateTime(now);
|
||||
businessOrderAccountMapper.insert(acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
||||
BeanUtil.copyProperties(order, detail, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties("id", "adjustId", "orderId", "createBy", "createName",
|
||||
"createTime", "updateBy", "updateTime", "delFlag",
|
||||
"orderSnapshotJson", "feeDetailJson"));
|
||||
try {
|
||||
detail.setOrderSnapshotJson(JSONUtil.toJsonStr(order));
|
||||
} catch (Exception e) {
|
||||
log.warn("生成调整快照JSON失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAdjustPass(Long adjustId, String auditBy, String auditByName, Date auditTime, String remark) {
|
||||
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
||||
adjust.setId(adjustId);
|
||||
adjust.setAuditStatus(AUDIT_PASS);
|
||||
adjust.setAuditBy(auditBy);
|
||||
adjust.setAuditByName(auditByName);
|
||||
adjust.setAuditTime(auditTime);
|
||||
adjust.setAuditRemark(remark);
|
||||
adjust.setUpdateBy(auditBy);
|
||||
adjust.setUpdateTime(auditTime);
|
||||
adjustMapper.updateById(adjust);
|
||||
}
|
||||
|
||||
private String[] toArray() {
|
||||
return PROTECTED_FIELDS.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void syncTmsAsync(String goodsNumber, BusinessDocumentOrder after) {
|
||||
try {
|
||||
List<ExecuteOrder> executeOrders = executeOrderMapper.selectList(
|
||||
new LambdaQueryWrapper<ExecuteOrder>()
|
||||
.eq(ExecuteOrder::getGoodsNumber, goodsNumber)
|
||||
.eq(ExecuteOrder::getDelFlag, 1));
|
||||
if (executeOrders == null || executeOrders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
log.info("业务单[{}]调整完成,关联执行单[{}]。如需回写TMS请接入TMS改费Feign。", goodsNumber,
|
||||
executeOrders.stream().map(ExecuteOrder::getGoodsNumber).collect(Collectors.toList()));
|
||||
} catch (Exception e) {
|
||||
log.error("同步TMS失败,不影响主流程", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -659,7 +659,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
private Date documentDate;
|
||||
|
||||
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回")
|
||||
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回 3-调整待审核")
|
||||
private Long reviewStatus;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
@@ -825,4 +825,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private String shuttleNo;
|
||||
|
||||
@ApiModelProperty("业务单调整状态 0-无 1-调整待审核 2-调整驳回 3-调整已通过")
|
||||
private Integer adjustStatus;
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjust.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整主记录
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("business_document_order_adjust")
|
||||
public class BusinessDocumentOrderAdjust implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("调整人账号")
|
||||
private String adjustBy;
|
||||
|
||||
@ApiModelProperty("调整人姓名")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("调整时间")
|
||||
private Date adjustTime;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("调整前业务单审核状态(review_status原值,用于调整审核通过/驳回后还原,避免影响其它)")
|
||||
private Long beforeReviewStatus;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("审核人账号")
|
||||
private String auditBy;
|
||||
|
||||
@ApiModelProperty("审核人姓名")
|
||||
private String auditByName;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
private Date auditTime;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private String orgId;
|
||||
|
||||
@ApiModelProperty("一级组织ID")
|
||||
private String topOrgId;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新人姓名")
|
||||
private String updateName;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||
private Integer delFlag;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjust.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整主记录 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessDocumentOrderAdjustMapper extends BaseMapper<BusinessDocumentOrderAdjust> {
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整明细(调整后业务单整行快照)
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("business_document_order_adjust_detail")
|
||||
public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("关联调整主记录ID")
|
||||
private Long adjustId;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("货物类型ID")
|
||||
private String goodsTypeId;
|
||||
|
||||
@ApiModelProperty("货物名称")
|
||||
private String goodsName;
|
||||
|
||||
@ApiModelProperty("车型")
|
||||
private String carType;
|
||||
|
||||
@ApiModelProperty("装货地")
|
||||
private String loadingName;
|
||||
|
||||
@ApiModelProperty("装货地址")
|
||||
private String loadingAddress;
|
||||
|
||||
@ApiModelProperty("装货时间")
|
||||
private Date loadingDate;
|
||||
|
||||
@ApiModelProperty("卸货地")
|
||||
private String unloadName;
|
||||
|
||||
@ApiModelProperty("卸货地址")
|
||||
private String unloadAddress;
|
||||
|
||||
@ApiModelProperty("卸货时间")
|
||||
private Date unloadingData;
|
||||
|
||||
@ApiModelProperty("发货人")
|
||||
private String freighterName;
|
||||
|
||||
@ApiModelProperty("装货电话")
|
||||
private String loadingPhone;
|
||||
|
||||
@ApiModelProperty("收货人")
|
||||
private String dischargerName;
|
||||
|
||||
@ApiModelProperty("卸货电话")
|
||||
private String unloadPhone;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty("线路")
|
||||
private String route;
|
||||
|
||||
@ApiModelProperty("单据日期")
|
||||
private Date documentDate;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private String orgId;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty("组织名称")
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty("一级组织ID")
|
||||
private Long topOrganizationId;
|
||||
|
||||
// ==================== 金额/费用快照 ====================
|
||||
@ApiModelProperty("发货运费")
|
||||
private BigDecimal deliveryFreight;
|
||||
|
||||
@ApiModelProperty("已收运费")
|
||||
private BigDecimal collectedFreight;
|
||||
|
||||
@ApiModelProperty("未收运费")
|
||||
private BigDecimal uncollectedFreight;
|
||||
|
||||
@ApiModelProperty("少收运费")
|
||||
private BigDecimal collectLessFreight;
|
||||
|
||||
@ApiModelProperty("运费单价(元/吨)")
|
||||
private BigDecimal transportationUnitPrice;
|
||||
|
||||
@ApiModelProperty("信息费")
|
||||
private BigDecimal infoFee;
|
||||
|
||||
@ApiModelProperty("计费单价")
|
||||
private BigDecimal freightUnitPrice;
|
||||
|
||||
@ApiModelProperty("货物保险金额")
|
||||
private BigDecimal cargoInsuranceAmount;
|
||||
|
||||
@ApiModelProperty("运费")
|
||||
private BigDecimal freightCharges;
|
||||
|
||||
@ApiModelProperty("运费")
|
||||
private BigDecimal freightFee;
|
||||
|
||||
@ApiModelProperty("卸货费")
|
||||
private BigDecimal unloadingFee;
|
||||
|
||||
@ApiModelProperty("报关费")
|
||||
private BigDecimal customsFee;
|
||||
|
||||
@ApiModelProperty("差货费")
|
||||
private BigDecimal shortageFee;
|
||||
|
||||
@ApiModelProperty("杂费")
|
||||
private BigDecimal miscellaneousFee;
|
||||
|
||||
@ApiModelProperty("其他费用")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
@ApiModelProperty("滞车费")
|
||||
private BigDecimal detentionFee;
|
||||
|
||||
@ApiModelProperty("税率")
|
||||
private BigDecimal taxRate;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("调整后业务单整行JSON快照(用于全字段精确还原)")
|
||||
private String orderSnapshotJson;
|
||||
|
||||
@ApiModelProperty("调整后费用明细JSON快照(business_order_account列表)")
|
||||
private String feeDetailJson;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjustDetail.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整明细 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessDocumentOrderAdjustDetailMapper extends BaseMapper<BusinessDocumentOrderAdjustDetail> {
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整 审核入参
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustAuditDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("调整记录ID(必传)")
|
||||
private Long adjustId;
|
||||
|
||||
@ApiModelProperty("审核结果 1-通过 2-驳回")
|
||||
private Integer auditResult;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整提交入参
|
||||
*
|
||||
* 前端整单回传 business_document_order 全部字段 + 费用明细 business_order_account:
|
||||
* - amountChanged=true (本次修改了金额) -> 需要业务主管审核
|
||||
* - amountChanged=false (仅改其它字段) -> 无需审核,直接更新
|
||||
*
|
||||
* order: 前端把「调整后」业务单整单字段回传(含 id 定位;deliveryFreight 合计可由后端按明细自动算)。
|
||||
* feeDetailList: 调整后费用明细(business_order_account),其 amount 之和 = 主表 deliveryFreight。
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("调整后业务单(整单字段,含 id 定位;金额合计 deliveryFreight 可由后端按明细自动算)")
|
||||
private BusinessDocumentOrder order;
|
||||
|
||||
@ApiModelProperty("调整后费用明细(business_order_account),amount 之和作为主表 deliveryFreight 合计")
|
||||
private List<BusinessOrderAccount> feeDetailList;
|
||||
|
||||
@ApiModelProperty("是否修改了金额(前端判定传入):true-需审核,false-直通")
|
||||
private Boolean amountChanged;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整记录 查询条件(管理列表用,可不按订单、查全部)
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustQueryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("业务单号(模糊)")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("调整人姓名(模糊)")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("所属组织ID(调整人/业务单所属组织)")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty("一级组织ID(组织隔离用)")
|
||||
private Long topOrganizationId;
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整记录(主记录) 列表/详情返回 VO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustRecordDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主记录ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("调整人账号")
|
||||
private String adjustBy;
|
||||
|
||||
@ApiModelProperty("调整人姓名")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("调整时间")
|
||||
private Date adjustTime;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("审核人账号")
|
||||
private String auditBy;
|
||||
|
||||
@ApiModelProperty("审核人姓名")
|
||||
private String auditByName;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
private Date auditTime;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
|
||||
@ApiModelProperty("调整后整行快照明细(详情查询时带出)")
|
||||
private BusinessDocumentOrderAdjustDetail detail;
|
||||
}
|
||||
+65
@@ -10,7 +10,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
|
||||
import com.mhd.oms.application.service.businessDocumentOrder.BusinessDocumentOrderAdjustService;
|
||||
import com.mhd.oms.application.service.businessDocumentOrder.BusinessDocumentOrderApplicationService;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
||||
import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import javax.annotation.Resource;
|
||||
@@ -33,6 +38,9 @@ public class BusinessDocumentOrderApi extends BaseController{
|
||||
@Resource
|
||||
private BusinessDocumentOrderAssembler businessDocumentOrderAssembler;
|
||||
|
||||
@Resource
|
||||
private BusinessDocumentOrderAdjustService businessDocumentOrderAdjustService;
|
||||
|
||||
/**
|
||||
* 分页查询【业务单】列表
|
||||
*/
|
||||
@@ -161,7 +169,64 @@ public class BusinessDocumentOrderApi extends BaseController{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 提交调整
|
||||
* 若修改了金额字段则进入调整待审核,否则直通更新
|
||||
*/
|
||||
@ApiOperation("订单调整 - 提交调整")
|
||||
@PostMapping("/adjust")
|
||||
public AjaxResult adjust(@RequestBody BusinessDocumentOrderAdjustDTO adjustDTO) {
|
||||
try {
|
||||
return businessDocumentOrderAdjustService.adjust(adjustDTO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 调整记录列表(查全部,可分页/按业务单号或审核状态筛选)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 调整记录列表")
|
||||
@GetMapping("/listAdjustRecord")
|
||||
public TableDataInfo listAdjustRecord(BusinessDocumentOrderAdjustQueryDTO query,
|
||||
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize) {
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
List<BusinessDocumentOrderAdjustRecordDTO> list = businessDocumentOrderAdjustService.listAdjustRecord(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 按业务单查询调整记录(供订单详情页展示)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 按业务单查询调整记录")
|
||||
@GetMapping("/listAdjustRecordByOrder/{orderId}")
|
||||
public AjaxResult listAdjustRecordByOrder(@PathVariable("orderId") Long orderId) {
|
||||
return AjaxResult.success(businessDocumentOrderAdjustService.listAdjustRecordByOrder(orderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 调整记录详情
|
||||
*/
|
||||
@ApiOperation("订单调整 - 调整记录详情")
|
||||
@GetMapping("/getAdjustRecord/{adjustId}")
|
||||
public AjaxResult getAdjustRecord(@PathVariable("adjustId") Long adjustId) {
|
||||
return AjaxResult.success(businessDocumentOrderAdjustService.getAdjustRecord(adjustId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 审核(通过/驳回)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 审核")
|
||||
@PostMapping("/auditAdjust")
|
||||
public AjaxResult auditAdjust(@RequestBody BusinessDocumentOrderAdjustAuditDTO auditDTO) {
|
||||
try {
|
||||
return businessDocumentOrderAdjustService.auditAdjust(auditDTO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user