27 Commits
Author SHA1 Message Date
rcx e60f22979c fix(wms): 补提交收货/上架单已反审归档详情接口(此前遗漏未入库)
getInfo 增加 archive 重载(归档主单已软删用getById放行+校验已反审标记,明细放行软删行)+ getReverseAuditInfo 接口,补齐对接文档承诺的4个归档详情接口中缺失的收货/上架两个;随附上架默认库位注释微调
2026-09-12 11:21:33 +08:00
rcx 84ff45b43d fix(oms): 批量审核运输业务单号重复(goods_number取号三层防线)
根因: 取号为「COUNT当日单量+1+查重后移」, 非原子、无锁、无唯一索引。
批量审核并发创建运输业务单时, 多请求在同一查重窗口取到同一序号并全部
插入成功, 且将同一单号回填到出库单business_number, 页面所见单号重复。

- GoodsNumberGenerator: 取号改为当日MAX+1+存在性校验后移; 按yyMMdd分段的
  JVM锁串行化"取号+插单"; 插单后自检同号自动改号自愈; 兼容唯一索引撞号重试
- BusinessDocumentOrderDomainService: 主创建入口改走原子"取号+插单",
  出库/入库单号回填移至插单成功之后
- BusinessDocumentOrderImpl: 审核拆单子单路径同改
- Mapper: countByGoodsNumberPrefix改为selectGoodsNumbersByPrefix
2026-09-12 10:09:11 +08:00
rcx 892cc30999 fix(oms): 出入库业务单下发执行单时订单来源继承业务单(数据导入/手动创建/系统生成)不再写死"客户预约"; 手动创建业务单来源为空兜底"手动创建"; 出库下发明细过滤del_flag, 修复编辑后软删旧明细参与仓库分组导致多生成执行单且数量叠加 2026-09-12 10:00:45 +08:00
rcx da76816533 fix(oms): 反审运输链路按拆单子单全量软删——执行单挂子单下(businessDocumentId=子单id), 主单+子单+执行单+TMS链全删; 执行单列表默认过滤归档行 2026-09-12 09:53:13 +08:00
rcx b86ab75dcf fix(oms,wms): WMS出库明细uniqueId撞键修复+推单返回值校验
- WMS反审/取消下发软删出库明细时置空uniqueId(表唯一约束不含del_flag)
- omsOrderAddDetail推单前自愈: 按本次推送uniqueId值跨执行单清归档行, 反审重发不再撞键
- OMS推单三处(单头/明细/配送明细)校验返回值, 失败报WMS真实原因, 不再静默吞掉后伪装成可用库存为0
- WmsServiceFeign三方法void改AjaxResult, 控制器与降级工厂同步
2026-09-11 16:07:21 +08:00
rcx 796bb99a8b fix(wms): 出库异常列表不再默认过滤已软删出库单, 反审生成的异常记录可见 2026-09-11 14:28:55 +08:00
rcx f9a50ae353 fix(oms): 出库反审核心改动(下发自愈/运输链路软删/issueStatus已驳回/uniqueId置空/仓库兜底切换) 2026-09-11 14:17:17 +08:00
rcx 2094ea31cd fix(oms): 仓库信息本地兜底查询去掉STOCK_LOCK_MODE列, 兜底不依赖冻结功能列, 修复无该列环境的下发报错 2026-09-11 13:52:28 +08:00
rcx 788bae9a16 fix(oms,wms): 出库反审补全——重新下发自愈/仓库信息本地兜底/运输链路反审联动/归档查询修复
- 反审后 issueStatus 置 3-已驳回(与入库侧同口径), 清空执行单号/货源单号
- 反审/取消下发软删执行明细时置空 uniqueId, 修复重新下发撞唯一约束
- 新增 WarehouseInfoApplicationService(Feign优先+本地跨库兜底), 出库侧8处调用点接入
- 反审联动软删运输链路: 运输业务单/执行单本地软删 + TMS deleteChainByExecuteOrderNumber
- WMS归档查询修复: 交接归档详情丢行/拣货归档数量恒0/复核列表归档汇总/OMS执行单已反审tab
2026-09-11 11:42:42 +08:00
rcx a65cca1cfa fix(oms,wms): 入库反审三项修复:反审记录不可见、反审后重新下发无法收货、异常列表JOIN过滤
1. 入库异常三个生成器(收货异常/上架异常/反审记录)插入时未显式设置delFlag,MyBatis-Plus insert不含该列,列无默认值落库为NULL,被列表del_flag=1过滤导致反审记录永远不可见;现显式setDelFlag(1)

2. 反审重置业务单status=1:首轮完成上架经WMS回传把业务单status写成5(已入库),不重置则重新下发时copy给执行单→W入库单→收货单,收货单带已完成状态导致前端不给收货按钮

3. 入库异常列表LEFT JOIN stock_in_order固定b.DEL_FLAG=1,反审记录关联的入库单已软删导致匹配不上,仓库等基于b表的过滤把行全部过滤掉、列表恒为空;改为按a.TYPE切换关联状态(type=3关联已软删入库单);收货/上架已反审tab同号多张入库单JOIN出重复行,限定只关联同状态最新一张(IN_ORDER_ID取max)
2026-09-11 09:41:21 +08:00
rcx cae62e83a5 fix(oms,wms): 入库反审修复:已反审tab列表查不到数据、未下发单反审补写反审记录
1. W收货单/W上架单【已反审】tab查不到数据:queryList 的 LEFT JOIN stock_in_order 固定带 a/b.DEL_FLAG=1,归档数据(反审后双方均已软删del_flag=2)关联不上b表,仓库/货主等基于b表的过滤条件把行全部过滤掉;改为按是否查反审归档动态切换关联条件(归档按del_flag=2关联,正常列表行为不变)

2. 未下发WMS的执行单反审不产生反审记录:reverseExecutionOrder 幂等跳过分支直接return导致入库异常无留痕;现补写1条反审记录(abnormalType=6,回退库存0,备注未下发WMS),同单号已有有效记录时防重,重试/重复反审幂等

3. OMS反审Feign参数透传组织三字段(organizationId/organizationName/topOrganizationId),供WMS跳过分支写反审记录使用(该场景无W入库单可取组织信息)
2026-09-10 17:25:07 +08:00
rcx e2da7177f0 fix(oms/wms): 出库明细出库时间过滤严格按出仓日期outbound_date(去除建档时间兜底),所见即所筛 2026-09-10 16:38:34 +08:00
rcx 0b45ad181f feat(oms/wms): 出库明细单据类型回显/查询条件/导出列补齐
- 出库明细查询新增orderTypeCode(精确)/orderTypeName(模糊)查询条件
- OMS出库明细SQL补查b.order_type_code/name,响应回显orderTypeCode/orderTypeName(原恒为null)
- WMS出库明细导出新增"业务单据类型"列(第31列)
2026-09-10 16:18:11 +08:00
rcx 260ec1f369 fix(oms): 出入库业务单反审补充清空执行单号/下发执行时间,修复反审后前端是否执行仍显示已执行 2026-09-10 14:24:43 +08:00
rcx b28575c34d fix(wms): 入库明细导出客户编号/客户名称改取货主编码与货主名称(与页面显示一致) 2026-09-10 14:04:06 +08:00
rcx 8af8197901 feat(oms/wms): 出入库明细货物种类改显物料分类名称、单据类型回显与查询条件
一、货物种类
- O/W出入库明细查询新增返回materialClassifyName(物料分类名称,多个逗号分隔)
- WMS入库导出"货物种类"列、出库导出"种类"列改为物料分类名称(原为goodsType编码转文字)
- OMS出入库导出新增"货物种类"列,货物类型列加字典转换不再显示0/1/2编码

二、单据类型
- O/W入库明细查询新增orderTypeCode/orderTypeName回显与查询条件(编码精确/名称模糊)
- WMS入库明细导出新增"业务单据类型"列(第31列)

三、时间字段
- OMS出库明细查询返回增加completeTime完成时间
- OMS orderOutboundDate出仓日期格式恢复为yyyy-MM-dd HH:mm:ss
- OMS出库时间过滤改为三级兜底:出库时间OUTBOUND_TIME→出仓日期→建档时间

四、修复
- WMS出库导出SQL修复TOTAL_PRICE列不存在(总价改用TOTAL_AMOUNT),总价值暂无来源占位空列
2026-09-10 11:35:30 +08:00
rcx 12f1d99e02 fix(wms): 出入库明细查询status字段改用独立SQL别名映射,避免同列双映射在增量构建下不可靠 2026-09-09 21:53:02 +08:00
rcx 244fbf9759 feat(wms): 出入库明细查询返回增加status字段(与outOrderStatus/inOrderStatus同值,便于前端绑定) 2026-09-09 18:20:44 +08:00
rcx e3826d6333 fix(oms): 出入库明细查询状态过滤口径修正-改为issue_status=4
问题:OMS执行出库单status不随WMS出库完成流转(回写代码被注释),推送创建的单据status也是默认值,
原过滤条件 status in(9,12,13)/status=5 会导致明细页查不到数据。

修复:
- 出库明细SQL:status in(9,12,13) 改为 issue_status=4(issueStatus: 0-已创建 2-已审核 3-已驳回 4-已出库)
- 入库明细SQL:status=5 改为 issue_status=4(WMS回写status=5时同步issueStatus=4,推送创建直接置4)
- 两个明细SQL新增返回 b.issue_status,前端状态列绑定issueStatus
- WithOrderPO新增issueStatus字段(导出"单据状态"列自动转文字),outOrderStatus/inOrderStatus保留返回但不再导出
2026-09-09 17:23:54 +08:00
rcx f217d6ec5c 发测试 2026-09-09 15:51:57 +08:00
rcx e58b6cb9ce feat(oms/wms): 出入库明细查询-已入库/已出库状态过滤、WMS新增出入库明细查询页面及专用导出
一、OMS 入库/出库明细查询(修复+导出)
- 出库明细SQL状态过滤由=9改为in(9,12,13):已出库/已复核/已交接均算已出库,与出库排名统计口径一致
- 入库明细SQL固定只统计已入库(status=5)单据
- 入/出库明细SQL新增实际入仓/出仓日期区间过滤(IFNULL(实际日期,建档时间)兜底),支持统计当天
- 新增Excel导出接口 /executionInMaterialDetailApi/exportWithOrder、/executionOutMaterialDetailApi/exportWithOrder(全量不分页)
- 退货回仓统计:通过入库单类型 inOrderTypeCode=tui_huo_ru_ku(退货入库)过滤

二、WMS 新增入库/出库明细查询页面
- 入库明细查询:GET /materialDetailApi/listWithOrder(明细关联入库单,固定已入库(5),level=1防父子行重复计数)
- 出库明细查询:GET /outMaterialDetailApi/listWithOrder(新建OutMaterialDetailApi,关联出库单,固定in(9,12,13))
- 返回单头字段:单据状态/审核状态/货主/供应商/客户/单据类型/实际入仓出仓日期/保额/货物类型等
- 入库客户编号/名称/客户预约名称经通知单号关联notice_order取得(入库单表无客户字段)

三、WMS 明细导出专用列集
- 出库导出/exportWithOrder:按客户要求30列导出,含出库单号/出库日期/客户信息/LOT号/费用组(单价、总价、折扣、仓租、合同收费)等
- 入库导出/exportWithOrder:按客户要求30列导出,含客户信息/入库日期/每件保额/收费标准/有效期等
- 单据状态、货物种类导出时自动转文字;导出列顺序与客户清单一致
- 火险保费、入库单件净重(KG)暂无数据来源,导出空列占位,待确认数据来源后补充

四、其他
- 查询条件不传日期时默认查全部日期,统计当天由前端传当天日期区间实现
- 数据权限:非平台超管按登录人一级组织过滤
2026-09-09 15:49:09 +08:00
rcx b7cacaeb8d feat(oms,wms): 入库业务单反审——业务单改已驳回+已反审tab,执行单/W入库/收货/上架软删打标归档,库存还原扣减,W入库异常反审记录
【需求】已入库/已出库的单子客户通知需要回退的场景,单子回退到最原始状态。反审入口在 OMS-入库业务单页面【反審單據】按钮,一次操作全链路回退。

【反审规则】
1. 按页面状态 issueStatus 判断:进行中(1)/已审核(2)/已入库(4)/部分完成(5) 可反审;已创建(0)无需反审、已驳回(3)可直接编辑;已取消/已关闭(status 6/7)兜底拦截
2. 已推送关务/NC(pushStatus=3)直接拦截,避免关务与仓内数据不一致
3. W入库单有出库记录就不能反审:按入库单号+动作(分配库存/出库)查询库存调整记录>0 即拦截,另校验库存冻结量>0
4. WMS无该单数据时幂等成功(未下发单反审),反审失败可安全重试

【反审动作】
1. 入库业务单:状态改为已驳回(issueStatus=3,与审核不通过同语义,可编辑→重新审核→重新下发),打已反审标记落入【已反审】tab;清空入库数量/入库时间/执行单号,明细 INBOUND_ITEMS/TOTAL_NET_WEIGHT 归零
2. 入库执行单+物料明细:软删(del_flag=2)+打已反审标记,【已反审】tab 按「已软删+已反审」查询归档数据,避免归档单被误审核/下发
3. WMS侧(逐执行单Feign omsReverseInOrder):库存还原扣减(校验库存行合计=已完成上架量后整行对称扣回,GREATEST(x-n,0)兜底)→ W入库单/W收货单/W上架单及明细、收货/上架作业单/任务/质检单整链软删+打已反审标记 → 写1条入库异常【反审记录】(type=3/abnormalType=6,FSYC单号)用于记录跟踪

【接口】
- POST /reservationStockInOrderApi/reverseAudit 反审(inOrderIds + reverseAuditRemark,支持批量)
- 已反审tab:/reservationStockInOrderApi/list?reverseAuditStatus=1(执行单/W入库单/W收货单/W上架单同参数,后端固定限定 del_flag=2+标记=1 归档数据)
- 归档详情:/executionStockInOrderApi、/stockInOrderApi、/stockReceiptOrderApi、/stockShelfOrderApi 各增 getReverseAuditInfo/{id}(原 getInfo 行为不变)
- 反审记录筛选:/inOrderAbnormalApi/list?abnormalType=6

【DDL】sql/20260908_oms_inbound_reverse_audit.sql:RESERVATION_STOCK_IN_ORDER / EXECUTION_STOCK_IN_ORDER / STOCK_IN_ORDER / STOCK_RECEIPT_ORDER / STOCK_SHELF_ORDER 各新增 REVERSE_AUDIT_STATUS/REMARK/BY/BY_NAME/TIME 五列,发服务前先执行

【其他】
- 库存扣减走 batchSubtractInventoryQuantity 并显式传更新人,规避 Feign 链路无登录态时 SecurityUtils 抛异常
- omsReverseInOrder 的 Feign 方法与降级已随出库反审提交(715883f1)入库,本次不再重复提交
- 归档行只读,详情走 getReverseAuditInfo;正常数据与归档数据互不干扰
2026-09-09 15:38:21 +08:00
rcx 715883f1d4 feat(oms,wms): 出库业务单反审——已出库/已审核单据回退已创建
- 新增 POST /reservationStockOutOrderApi/reverseAudit,按issueStatus(2-已审核/4-已出库)判断可反审
- 主单回退已创建并打reverseStatus标记,进【已反审】tab(list status=-2),重新审核通过自动复位
- 执行单/明细软删+reverseFlag=1,预约库存调整记录软删
- WMS新增/stockOutOrderApi/omsReverseExecutionOrder:已出库还原实物库存+推OMS,未出库仅还原分配占用,WMS无数据幂等成功
- W出库/拣货/复核/交接单软删+reverseFlag=1,列表支持delFlag=2&reverseFlag=1【已反审】tab
- 四页面新增归档详情接口getReverseInfo*
- 生成出库异常记录【反审记录】(abnormalType=3,前缀FSYC)
- 需先执行SQL: 20260908两个反审脚本(OMS库+WMS库)
2026-09-09 15:20:13 +08:00
rcx 139a3a82da feat(wms): 盘点单详情investigetionManageDetailList按物料编码排序,相同编码相邻展示(仅排序不聚合) 2026-09-09 14:18:48 +08:00
rcx fcc8102d9e feat(wms): 库存调整记录列表新增按入库单号(inOrderNumber)查询 2026-09-09 14:16:32 +08:00
rcx 7649585715 发测试 2026-09-09 09:27:57 +08:00
rcx 7511d211c6 fix(wms): 修复盘点详情批次属性attributeValue为空的问题
1. 标签映射表改LinkedHashMap固定优先级,补全批次号/入库日期/生产日期/过期日期及英文标签映射
2. fieldName反射取不到值时回退按batchLabels映射再取,修复fieldName配置失效导致值永远为空
3. batchDetailId为空的批次属性配置行不再丢弃,改为batchDetailId+标签双重去重
2026-09-09 09:14:01 +08:00
202 changed files with 4419 additions and 1943 deletions
@@ -19,8 +19,7 @@ import java.util.Set;
/**
* bms财务结算系统feign调用接口
*/
// 目标地址由 nacos 配置项 feign.url.mhd-bms-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.33.0.109:8012",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface BmsServiceFeign {
@@ -17,8 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.concurrent.CompletableFuture;
// 目标地址由 nacos 配置项 feign.url.mhd-oms-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017",fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.33.0.99:8017",fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface OmsServiceFeign {
@@ -26,8 +26,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
// 目标地址由 nacos 配置项 feign.url.mhd-wlhy-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.33.0.129:8014",configuration = FeignAutoConfiguration.class)
public interface WlhyServiceFeign {
/**
@@ -540,6 +539,13 @@ public interface WlhyServiceFeign {
@GetMapping("/feign/order/cancelIssueDocuments")
public AjaxResult cancelIssueDocuments(@RequestParam(name="executeOrderId") String executeOrderId);
/**
* OMS出库业务单反审联动: 按执行单货源编号软删TMS整条链路(货源单->运单->运输作业单, is_delete=1), 幂等,
* 与 cancelIssueDocuments(仅关闭货源单且有有效运单即拒绝)不同, 反审口径不留TMS数据
*/
@PostMapping("/feign/order/deleteChainByExecuteOrderNumber")
public AjaxResult deleteChainByExecuteOrderNumber(@RequestParam(name="executeOrderNumber") String executeOrderNumber);
@GetMapping(value = "/ntocc/tmsSettlementExchangeRate/queryList")
public AjaxResult<?> queryList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@@ -21,8 +21,7 @@ import java.util.Map;
* @description: TODO
* @date 2024/5/10 8:58
**/
// 目标地址由 nacos 配置项 feign.url.mhd-wms-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE,url = "http://10.102.192.32:8016",fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE,url = "http://10.33.0.109:8016",fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface WmsServiceFeign {
/**
@@ -75,21 +74,21 @@ public interface WmsServiceFeign {
*/
@ApiOperation("oms下发单保存")
@PostMapping(value = "/stockOutOrderApi/omsOutOrderAdd")
public void omsOutOrderAdd(@RequestBody StockOutOrder stockOutOrder);
public AjaxResult omsOutOrderAdd(@RequestBody StockOutOrder stockOutOrder);
/**
* oms下发单明细保存
*/
@ApiOperation("oms下发单明细保存")
@PostMapping(value = "/stockOutOrderApi/omsOutOrderAddDetail")
public void omsOutOrderAddDetail(@RequestBody List<OutMaterialDetail> outMaterialDetails);
public AjaxResult omsOutOrderAddDetail(@RequestBody List<OutMaterialDetail> outMaterialDetails);
/**
* oms下发单明细保存
*/
@ApiOperation("oms下发单明细保存")
@PostMapping(value = "/stockOutOrderApi/omsOutOrderAddDeliveryDetailsLink")
public void omsOutOrderAddDeliveryDetailsLink(@RequestBody List<DeliveryDetailsLink> deliveryDetailsLinks);
public AjaxResult omsOutOrderAddDeliveryDetailsLink(@RequestBody List<DeliveryDetailsLink> deliveryDetailsLinks);
/**
@@ -134,6 +133,27 @@ public interface WmsServiceFeign {
@PostMapping(value = "/stockInOrderApi/omsCancelInOrder")
public AjaxResult omsCancelInOrder(@RequestBody StockInOrder stockInOrder);
/**
* oms出库执行单反审(已出库/已复核单据客户通知回退场景):WMS侧还原实物库存并推送OMS库存、
* 逻辑删除出库链路单据、生成1条出库异常【反审记录】;反审原因经 remark 透传。
* 已产生下游不可逆数据时返回错误,OMS据此整体回滚。
*/
@ApiOperation("oms出库执行单反审WMS回退")
@PostMapping(value = "/stockOutOrderApi/omsReverseExecutionOrder")
public AjaxResult omsReverseExecutionOrder(@RequestBody StockOutOrder stockOutOrder);
/**
* oms入库业务单反审:WMS侧一个事务内回退已入库/收货中/上架中单据——
* 校验未产生出库(按入库单号+动作"分配库存/出库"查库存调整记录>0即有出库) ->
* 按库存行整行回退库存扣减 -> 软删W入库单/W收货单/W上架单全链并打已反审标记
* (各页面【已反审】tab按"已软删+已反审"查询归档数据)-> 写1条入库异常【反审记录】(type=3)。
* 入参: inOrderNumber=执行入库单号, remark=业务单号+反审原因, updateBy/updateByName=反审人;
* WMS无该单数据时幂等返回成功(未下发单反审不产生WMS数据)。
*/
@ApiOperation("oms入库单反审WMS回退")
@PostMapping(value = "/stockInOrderApi/omsReverseInOrder")
public AjaxResult omsReverseInOrder(@RequestBody StockInOrder stockInOrder);
@ApiOperation("oms查询物料列表")
@GetMapping("/materialBaseInfoApi/queryList")
public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO);
@@ -13,8 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Map;
// 目标地址由 nacos 配置项 feign.url.xxl-job-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://10.102.192.32:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://127.0.0.1:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface XxlJobServiceFeign {
@@ -9,8 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
// 目标地址由 nacos 配置项 feign.url.mhd-yms-service 指定,未配置时按服务名走服务发现
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "http://10.102.192.32:8018",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "http://10.33.0.99:8018",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface YmsServiceFeign {
/**
@@ -551,6 +551,12 @@ public class RemoteWlhyFallbackFactory implements FallbackFactory<WlhyServiceFei
return AjaxResult.error(cause.getMessage());
}
@Override
public AjaxResult deleteChainByExecuteOrderNumber(String executeOrderNumber) {
//返回错误而非静默成功, 让OMS反审事务能感知失败并整体回滚
return AjaxResult.error("TMS反审联动软删链路失败(服务降级):" + cause.getMessage());
}
@Override
public AjaxResult<?> queryList(Integer pageNo, Integer pageSize, String pushStatus, String organizationId) {
return AjaxResult.error(cause.getMessage());
@@ -57,16 +57,19 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
}
@Override
public void omsOutOrderAdd(StockOutOrder stockOutOrder) {
public AjaxResult omsOutOrderAdd(StockOutOrder stockOutOrder) {
//返回错误而非静默成功: 降级吞掉会让OMS继续走分配, 残留"有单无明细"的垃圾单
return AjaxResult.error("WMS下发单保存失败(服务降级):" + cause.getMessage());
}
@Override
public void omsOutOrderAddDetail(List<OutMaterialDetail> outMaterialDetails) {
public AjaxResult omsOutOrderAddDetail(List<OutMaterialDetail> outMaterialDetails) {
return AjaxResult.error("WMS下发单明细保存失败(服务降级):" + cause.getMessage());
}
@Override
public void omsOutOrderAddDeliveryDetailsLink(List<DeliveryDetailsLink> deliveryDetailsLinks) {
public AjaxResult omsOutOrderAddDeliveryDetailsLink(List<DeliveryDetailsLink> deliveryDetailsLinks) {
return AjaxResult.error("WMS下发单配送明细保存失败(服务降级):" + cause.getMessage());
}
@Override
@@ -82,6 +85,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
return AjaxResult.error("WMS取消下发清理失败:" + cause.getMessage());
}
@Override
public AjaxResult omsReverseExecutionOrder(StockOutOrder stockOutOrder) {
//返回错误而非静默成功,让OMS反审事务能感知失败并整体回滚
return AjaxResult.error("WMS出库执行单反审失败(服务降级):" + cause.getMessage());
}
@Override
public void omsAutoAssign(StockOutOrderDTO stockOutOrderDTO) {
@@ -110,6 +119,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
return AjaxResult.error("WMS取消下发清理失败:" + cause.getMessage());
}
@Override
public AjaxResult omsReverseInOrder(StockInOrder stockInOrder) {
//返回错误而非静默成功,让OMS侧反审能感知回退失败并整体回滚(反审可重试,WMS回退幂等)
return AjaxResult.error("WMS入库单反审回退失败(服务降级):" + cause.getMessage());
}
@Override
public TableDataInfo getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) {
TableDataInfo tableDataInfo = new TableDataInfo();
@@ -130,11 +130,9 @@ public class TokenLoginApplicationService {
//验证码登录校验验证码
String key = CacheConstants.SMS_LOGIN + userPhone;
Object object = redisService.getCacheObject(key) == null ? "":redisService.getCacheObject(key);
if (loginDTO.getWechatFlag() != 1) {
// if (!ObjectUtil.equal(String.valueOf(object), verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)) {
// recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
throw new ServiceException("验证码错误");
// }
if(!ObjectUtil.equal(String.valueOf(object),verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)){
recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
throw new ServiceException("验证码错误");
}
//获取包名对应的业务(存在需要查询业务,不存在保存为无业务模式)
@@ -170,13 +168,7 @@ public class TokenLoginApplicationService {
throw new ServiceException("对不起,您的账号:" + userPhone + " 已停用");
}
//校验验证码是否正确
if (loginDTO.getWechatFlag() != 1) {
// if (!ObjectUtil.equal(String.valueOf(object), verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)) {
// recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
throw new ServiceException("验证码错误");
// }
}
// sysPasswordService.validate(userPo, verificationCode, 1, null);
sysPasswordService.validate(userPo, verificationCode, 1, null);
}
return userInfo;
}
@@ -40,7 +40,4 @@ public class LoginDTO {
@ApiModelProperty(name = "组织名称(司机选择组织时传入)")
private String organizationName;
@ApiModelProperty(name = "微信标识")
private Integer wechatFlag;
}
+4 -4
View File
@@ -12,10 +12,10 @@ spring:
cloud:
nacos:
discovery:
# server-addr: 127.0.0.1:8848
server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
# server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
#线上正式环境
@@ -23,8 +23,8 @@ spring:
# username: nacos
# password: manhuoda@2023
config:
# server-addr: 127.0.0.1:8848
server-addr: 10.102.192.31:6848
server-addr: 127.0.0.1:8848
# server-addr: 10.102.192.31:6848
# 测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
# 线上测试环境配置 容器名+端口号
@@ -7,9 +7,6 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
import java.util.List;
@@ -29,27 +26,18 @@ public interface BiPlatformRealDataMapper {
/** 今日作业任务数 */
Long countTodayTasks();
/** 车辆状态统计(今日,含叫号状态合计 callStatusTotal = 已签到+已叫号+已过号 */
/** 车辆状态统计(今日) */
RealVehicleStatusPO queryVehicleStatusToday();
/** 本月任务量 */
Long countMonthTasks();
/** 本月任务平均时长 / 完成率统计 */
RealMonthlyTaskDurationPO queryMonthTaskStats();
/** 任务负荷(今日 24 小时) */
List<RealTaskLoadPO> queryTaskLoadToday();
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
/** 今日作业准时率统计(total 今日预约总数;onTimeCount 今日准时车辆数) */
RealOnTimeStatPO queryTodayOnTimeStats();
/** 任务类型统计(本月 YMS QMS_MAIN_BUSINESS 预约按业务类型 BUSINESS_NAME 分组) */
List<RealTaskTypeStatPO> queryMonthTransportOrderByType();
/** 月台监控-按楼层统计月台车辆(楼层、月台数量、今日预约车辆、当前作业车辆) */
List<RealPlatformFloorStatPO> queryPlatformFloorStats();
@@ -1,29 +0,0 @@
package com.mhd.bi.domain.biPlatformRealData.repository.po;
import lombok.Data;
import java.io.Serializable;
/**
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS
* avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与)
* durationCount:参与平均时长统计的有效条数
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
* totalCount:本月(TARGET_DATE)预约总数量
*/
@Data
public class RealMonthlyTaskDurationPO implements Serializable {
private static final long serialVersionUID = 1L;
/** 平均作业时长(小时) */
private Double avgDurationHours;
/** 参与平均时长统计的有效条数 */
private Long durationCount;
/** 本月已出场数量 */
private Long completedCount;
/** 本月预约总数量(按 TARGET_DATE 统计) */
private Long totalCount;
}
@@ -1,20 +0,0 @@
package com.mhd.bi.domain.biPlatformRealData.repository.po;
import lombok.Data;
import java.io.Serializable;
/**
* 今日作业准时率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS
* 准时率 = 今日实际进场时间在预约日期当天的车辆数 / 今日预约总车辆数 × 100%
*/
@Data
public class RealOnTimeStatPO implements Serializable {
private static final long serialVersionUID = 1L;
/** 今日预约总车辆数 */
private Long total;
/** 今日准时车辆数(已进场且实际进场日期 = 预约日期) */
private Long onTimeCount;
}
@@ -1,20 +0,0 @@
package com.mhd.bi.domain.biPlatformRealData.repository.po;
import lombok.Data;
import java.io.Serializable;
/**
* 任务类型统计(真实数据,来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表)
* 按本月预约车辆数(TARGET_DATE 在当前月)以 BUSINESS_NAME 业务类型分组
*/
@Data
public class RealTaskTypeStatPO implements Serializable {
private static final long serialVersionUID = 1L;
/** 业务类型名称(qms_main_business.BUSINESS_NAME */
private String businessName;
/** 该业务类型本月预约车辆数 */
private Long count;
}
@@ -16,12 +16,6 @@ public class RealVehicleStatusPO implements Serializable {
/** 当前未签到 */
private Long notCheckedIn;
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
private Long waiting;
/** 叫号状态合计:已签到 + 已叫号 + 已过号(FLOW_STATUS IN '2','3','4',预约日期为今天) */
private Long callStatusTotal;
/** 当前作业中 */
private Long operatingVehicles;
@@ -9,19 +9,12 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@@ -98,27 +91,16 @@ public class BiPlatformRealDataService {
if (vo.getPlatformOverview() != null) {
fp.put("totalPlatforms", vo.getPlatformOverview().getTotalPlatforms());
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
}
if (vo.getEfficiencyStatistics() != null) {
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
}
if (vo.getVehicleStatus() != null) {
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
fp.put("waiting", vo.getVehicleStatus().getWaiting());
fp.put("callStatusTotal", vo.getVehicleStatus().getCallStatusTotal());
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
}
if (vo.getMonthlyTaskStatistics() != null) {
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration());
fp.put("taskCompletionRate", vo.getMonthlyTaskStatistics().getTaskCompletionRate());
}
if (vo.getVehicles() != null) {
List<Map<String, Object>> vehicles = new ArrayList<>();
@@ -144,27 +126,6 @@ public class BiPlatformRealDataService {
}
fp.put("taskLoadStatistics", loads);
}
if (vo.getTaskTypeStatistics() != null) {
Map<String, Object> m = new LinkedHashMap<>();
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
List<Map<String, Object>> types = new ArrayList<>();
for (TaskTypeCountItemVO it : vo.getTaskTypeStatistics().getTaskTypes()) {
Map<String, Object> tm = new LinkedHashMap<>();
tm.put("type", it.getType());
tm.put("count", it.getCount());
types.add(tm);
}
m.put("taskTypes", types);
}
fp.put("taskTypeStatistics", m);
}
// 月台告警统计:按业务要求恒为 0,纳入指纹以确保旧快照(可能含非0写死值)能被覆盖更新为 0
if (vo.getPlatformAlarmStatistics() != null) {
fp.put("todayAlarmTotal", vo.getPlatformAlarmStatistics().getTodayAlarmTotal());
fp.put("handled", vo.getPlatformAlarmStatistics().getHandled());
fp.put("unhandled", vo.getPlatformAlarmStatistics().getUnhandled());
}
return objectMapper.writeValueAsString(fp);
}
@@ -205,34 +166,12 @@ public class BiPlatformRealDataService {
}
}
/**
* 今日作业准时率 = 今日准时车辆数 / 今日有入场时间的车辆数 × 100%(四舍五入取整)
* 准时:实际进入时间 < 预约日期(TARGET_DATE) + 预约结束时间(BOOKING_END_TIME)。
* 分子分母都只统计有入场时间(ENTRY_TIME 不为空)的车辆;分母为 0 时返回 0。
*/
public int calcTodayOnTimeRate() {
try {
RealOnTimeStatPO po = biPlatformRealDataMapper.queryTodayOnTimeStats();
if (po == null) return 0;
long total = po.getTotal() == null ? 0L : po.getTotal();
long onTime = po.getOnTimeCount() == null ? 0L : po.getOnTimeCount();
if (total <= 0) return 0;
// 四舍五入到整数百分比(取整)
return (int) Math.round(((double) onTime / (double) total) * 100.0);
} catch (Exception e) {
log.error("【YMS】计算今日作业准时率失败: {}", e.getMessage(), e);
return 0;
}
}
public RealVehicleStatusPO queryVehicleStatusToday() {
try {
RealVehicleStatusPO po = biPlatformRealDataMapper.queryVehicleStatusToday();
if (po == null) po = new RealVehicleStatusPO();
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
if (po.getWaiting() == null) po.setWaiting(0L);
if (po.getCallStatusTotal() == null) po.setCallStatusTotal(0L);
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
return po;
@@ -241,14 +180,10 @@ public class BiPlatformRealDataService {
RealVehicleStatusPO po = new RealVehicleStatusPO();
po.setTodayReservedVehicles(0L);
po.setNotCheckedIn(0L);
po.setWaiting(0L);
po.setCallStatusTotal(0L);
po.setOperatingVehicles(0L);
po.setCompletedVehicles(0L);
return po;
}
}
public long countMonthTasks() {
@@ -261,21 +196,6 @@ public class BiPlatformRealDataService {
}
}
/**
* 本月任务平均时长 / 完成率统计:
* - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
*/
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
try {
return biPlatformRealDataMapper.queryMonthTaskStats();
} catch (Exception e) {
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
return null;
}
}
public List<RealTaskLoadPO> queryTaskLoadToday() {
try {
return biPlatformRealDataMapper.queryTaskLoadToday();
@@ -285,35 +205,6 @@ public class BiPlatformRealDataService {
}
}
/**
* 任务类型统计:本月(YMS QMS_MAIN_BUSINESS)预约车辆按业务类型 BUSINESS_NAME 分组;
* 返回 {totalTasks: 当月总预约车辆数, taskTypes: [{type: 业务类型名称, count: 该类型预约数}]}
* 按真实 BUSINESS_NAME 分组输出,不固定兜底类别;当月无数据或查询失败时返回空列表。
*/
public TaskTypeStatisticsVO queryMonthTransportOrderByType() {
List<TaskTypeCountItemVO> items = new ArrayList<>();
int total = 0;
try {
List<RealTaskTypeStatPO> rows = biPlatformRealDataMapper.queryMonthTransportOrderByType();
if (rows != null) {
for (RealTaskTypeStatPO r : rows) {
if (r == null || r.getBusinessName() == null || r.getCount() == null) {
continue;
}
int c = r.getCount().intValue();
items.add(TaskTypeCountItemVO.builder().type(r.getBusinessName()).count(c).build());
total += c;
}
}
} catch (Exception e) {
log.error("【YMS】统计当月预约业务类型失败: {}", e.getMessage(), e);
// 查询失败返回空列表(前端会显示空)
items = new ArrayList<>();
total = 0;
}
return TaskTypeStatisticsVO.builder().totalTasks(total).taskTypes(items).build();
}
/**
* 今日预约-业务类型统计:按业务类型分组统计今日预约数量。
* 例:今日预约航空打板 3 条 → 返回 {businessName:"航空打板", count:3}
@@ -380,68 +271,29 @@ public class BiPlatformRealDataService {
template.setVehicles(vehicleVos);
// 月台实时概览:真实数据源,无条件覆盖
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFOJOB_STATUS=1 表示占用)
// 月台占用率 = 占用 / 全部月台
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
// 作业准时率 = 今日(实际进场时间在预约日期当天的车辆数) / 今日预约车辆总数 × 100%
if (template.getPlatformOverview() != null) {
List<RealPlatformInfoPO> platformList = queryPlatformInfoList();
int total = platformList == null ? 0 : platformList.size();
int occ = 0;
if (platformList != null) {
for (RealPlatformInfoPO p : platformList) {
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
occ++;
}
}
}
RealPlatformOverviewPO ov = queryPlatformOverview();
int total = ov.getTotalPlatforms().intValue();
int occ = ov.getOperatingPlatforms().intValue();
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
int todayTasks = (int) countTodayTasks();
template.getPlatformOverview().setTotalPlatforms(total);
template.getPlatformOverview().setOperatingPlatforms(occ);
template.getPlatformOverview().setCurrentOccupancyRate(rate);
template.getPlatformOverview().setTodayTasks(todayTasks);
// 作业准时率(实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100% 取整)
if (template.getEfficiencyStatistics() != null) {
template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate());
}
template.getPlatformOverview().setTodayTasks((int) countTodayTasks());
}
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号)
// 作业车辆状态统计:真实数据源,无条件覆盖
if (template.getVehicleStatus() != null) {
RealVehicleStatusPO vs = queryVehicleStatusToday();
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal().intValue());
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
}
// 本月任务统计:taskTotal / avgTaskDuration / taskCompletionRate 均有真实数据源,无条件覆盖;YoY 保留模板写死值
// 本月任务统计:taskTotal 有真实数据源无条件覆盖;YoY 等无真实数据源保留模板写死值
if (template.getMonthlyTaskStatistics() != null) {
template.getMonthlyTaskStatistics().setTaskTotal((int) countMonthTasks());
RealMonthlyTaskDurationPO monthStats = queryMonthTaskStats();
if (monthStats != null) {
if (monthStats.getAvgDurationHours() != null) {
// 保留两位小数
double v = monthStats.getAvgDurationHours();
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
}
Long total = monthStats.getTotalCount();
Long completed = monthStats.getCompletedCount();
if (total != null && total > 0 && completed != null) {
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
} else {
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
}
}
}
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
@@ -461,9 +313,6 @@ public class BiPlatformRealDataService {
}
}
// 任务类型统计:本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组(真实业务数据)
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
return template;
}
@@ -87,9 +87,7 @@ public final class BiReportSnapshotMapperSupport {
.platformOverview(PlatformOverviewVO.builder()
.totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build())
.vehicleStatus(VehicleStatusVO.builder()
.todayReservedVehicles(0).notCheckedIn(0).waiting(0)
.callStatusTotal(0)
.operatingVehicles(0).completedVehicles(0).build())
.todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build())
.avgOperationDurationTrend(Collections.emptyList())
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
@@ -16,7 +16,7 @@ import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperat
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
import lombok.RequiredArgsConstructor;
@@ -173,31 +173,18 @@ public class BiReportSnapshotSyncService {
}
// ====== 真实数据:月台实时概览 ======
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFOJOB_STATUS=1 表示占用)
// 月台占用率 = 占用 / 全部月台
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
RealPlatformOverviewPO ov = biPlatformRealDataService.queryPlatformOverview();
if (template.getPlatformOverview() != null) {
List<RealPlatformInfoPO> platformList = biPlatformRealDataService.queryPlatformInfoList();
int total = platformList == null ? 0 : platformList.size();
int occ = 0;
if (platformList != null) {
for (RealPlatformInfoPO p : platformList) {
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
occ++;
}
}
}
template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue());
template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue());
int total = ov.getTotalPlatforms().intValue();
int occ = ov.getOperatingPlatforms().intValue();
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
int todayTasks = (int) biPlatformRealDataService.countTodayTasks();
template.getPlatformOverview().setTotalPlatforms(total);
template.getPlatformOverview().setOperatingPlatforms(occ);
template.getPlatformOverview().setCurrentOccupancyRate(rate);
template.getPlatformOverview().setTodayTasks(todayTasks);
// 作业准时率 = 实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100%(取整)
if (template.getEfficiencyStatistics() != null) {
template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate());
}
}
long todayTasks = biPlatformRealDataService.countTodayTasks();
if (template.getPlatformOverview() != null) {
template.getPlatformOverview().setTodayTasks((int) todayTasks);
}
// ====== 真实数据:作业车辆状态统计 ======
@@ -205,36 +192,14 @@ public class BiReportSnapshotSyncService {
if (template.getVehicleStatus() != null) {
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal() == null ? 0 : vs.getCallStatusTotal().intValue());
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
}
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
// ====== 真实数据:本月任务统计 taskTotal ======
long monthTasks = biPlatformRealDataService.countMonthTasks();
if (template.getMonthlyTaskStatistics() != null) {
template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks);
com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO monthStats =
biPlatformRealDataService.queryMonthTaskStats();
if (monthStats != null) {
if (monthStats.getAvgDurationHours() != null) {
double v = monthStats.getAvgDurationHours();
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
}
Long total = monthStats.getTotalCount();
Long completed = monthStats.getCompletedCount();
if (total != null && total > 0 && completed != null) {
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
} else {
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
}
}
}
// ====== 真实数据:任务负荷(今日 24 小时) ======
@@ -253,9 +218,6 @@ public class BiReportSnapshotSyncService {
}
}
// ====== 真实数据:任务类型统计(本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组) ======
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
return template;
}
@@ -155,13 +155,10 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
VehicleStatusVO vs = VehicleStatusVO.builder()
.todayReservedVehicles(Math.max(0, jitterInt(Baseline.P_RESV, r)))
.notCheckedIn(Math.max(0, jitterInt(Baseline.P_NC, r)))
.waiting(Math.max(0, jitterInt(Baseline.P_WAIT, r)))
.callStatusTotal(Math.max(0, jitterInt(Baseline.P_CALL_STATUS_TOTAL, r)))
.operatingVehicles(Math.max(0, jitterInt(Baseline.P_OPV, r)))
.completedVehicles(Math.max(0, jitterInt(Baseline.P_DONE, r)))
.build();
List<AvgOperationDurationTrendItemVO> avgTrend = new ArrayList<>();
for (int i = 0; i < Baseline.P_MO_LABELS.length; i++) {
avgTrend.add(AvgOperationDurationTrendItemVO.builder()
@@ -188,8 +185,13 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
.build());
}
// 月台告警:按业务要求,全部置 0(趋势/统计/分布均不生成写死数据)
List<PlatformAlarmTrendItemVO> alarmTrend = new ArrayList<>();
for (int i = 0; i < Baseline.P_AL_D.length; i++) {
alarmTrend.add(PlatformAlarmTrendItemVO.builder()
.date(Baseline.P_AL_D[i])
.alarmCount(Math.max(0, jitterInt(Baseline.P_AL_C[i], r)))
.build());
}
List<TaskTypeCountItemVO> typeCounts = new ArrayList<>();
for (int i = 0; i < Baseline.P_TT_TYPES.length; i++) {
@@ -199,11 +201,18 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
.build());
}
int todayAl = 0;
int handled = 0;
int unhandled = 0;
int todayAl = Math.max(0, jitterInt(Baseline.P_AL_TOT, r));
int handled = Math.max(0, jitterInt(Baseline.P_AL_H, r));
handled = Math.min(handled, todayAl);
int unhandled = Math.max(0, todayAl - handled);
List<PlatformAlarmDistItemVO> dist = new ArrayList<>();
for (int i = 0; i < Baseline.P_DIST_T.length; i++) {
dist.add(PlatformAlarmDistItemVO.builder()
.type(Baseline.P_DIST_T[i])
.count(Math.max(0, jitterInt(Baseline.P_DIST_C[i], r)))
.build());
}
return PlatformSurveillanceVO.builder()
.vehicles(vehicles)
@@ -406,8 +415,6 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
static final int P_TASKS = 418;
static final int P_RESV = 2_850;
static final int P_NC = 920;
static final int P_WAIT = 680;
static final int P_CALL_STATUS_TOTAL = 680;
static final int P_OPV = 1_180;
static final int P_DONE = 1_420;
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
@@ -20,12 +20,6 @@ public class VehicleStatusVO {
@ApiModelProperty("当前未签到,单位:辆")
private Integer notCheckedIn;
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
private Integer waiting;
@ApiModelProperty("已签到+已叫号+已过号(FLOW_STATUS IN 2/3/4),单位:辆")
private Integer callStatusTotal;
@ApiModelProperty("当前作业中,单位:辆")
private Integer operatingVehicles;
+2 -2
View File
@@ -19,14 +19,14 @@ spring:
# username: nacos
# password: manhuoda@2023
#线上正式环境
server-addr: 10.102.192.31:6848
server-addr: 10.102.192.30:6848
username: nacos
password: manhuoda@2023
config:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
server-addr: 10.102.192.30:6848
username: nacos
password: manhuoda@2023
#线上正式环境
@@ -40,85 +40,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO
</select>
<!-- 今日作业任务:按预约时间 TARGET_DATE(今日)统计主业务记录数 -->
<!-- 今日作业任务:实际进入时间是今日的 -->
<select id="countTodayTasks" resultType="java.lang.Long">
SELECT COUNT(1)
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
WHERE TARGET_DATE IS NOT NULL
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
</select>
<!-- 今日作业准时率统计:
total 今日有入场时间的预约车辆数(ENTRY_TIME 不为空 且 TARGET_DATE = 今天)
onTimeCount 今日准时车辆数(实际进入时间 < 预约日期 + 预约结束时间 BOOKING_END_TIME,即 ENTRY_TIME < TRUNC(TARGET_DATE) + 预约时段结束时分)
「准时率 = 今日准时车辆数 / 今日有入场时间的车辆数 × 100%(四舍五入取整);分子分母都只统计有入场时间的车辆」
BOOKING_END_TIME 存纯时分(如 18:30),故用 TO_DATE 解析后取其时分间隔加到 TARGET_DATE 上
-->
<select id="queryTodayOnTimeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO">
SELECT
SUM(CASE WHEN ENTRY_TIME IS NOT NULL
AND TARGET_DATE IS NOT NULL
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS total,
SUM(CASE WHEN ENTRY_TIME IS NOT NULL
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
AND ENTRY_TIME &lt; TRUNC(TARGET_DATE)
+ (TO_DATE(BOOKING_END_TIME, 'HH24:MI') - TRUNC(TO_DATE(BOOKING_END_TIME, 'HH24:MI')))
THEN 1 ELSE 0 END) AS onTimeCount
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
WHERE ENTRY_TIME IS NOT NULL
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
</select>
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
callStatusTotal 叫号状态合计:已签到 + 已叫号 + 已过号 = FLOW_STATUS IN ('2','3','4') 且 预约日期 = 今天
FLOW_STATUS: 1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 -->
<select id="queryVehicleStatusToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO">
SELECT
SUM(CASE WHEN TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
SUM(CASE WHEN FLOW_STATUS = '1' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS notCheckedIn,
SUM(CASE WHEN FLOW_STATUS IN ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
SUM(CASE WHEN FLOW_STATUS IN ('2','3','4') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS callStatusTotal,
SUM(CASE WHEN FLOW_STATUS IN ('5','6','7','8','9','10') AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS operatingVehicles,
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
</select>
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
<!-- 本月任务量:实际进入时间是本月的 -->
<select id="countMonthTasks" resultType="java.lang.Long">
SELECT COUNT(1)
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
WHERE TARGET_DATE IS NOT NULL
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
WHERE ENTRY_TIME IS NOT NULL
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
</select>
<!-- 本月任务平均作业时长 / 完成率统计:
avgDurationHours 平均时长(小时)= AVG((EXIT_TIME - ENTRY_TIME) * 24)
仅 ENTRY_TIME 与 EXIT_TIME 都不为空时参与;
durationCount 参与平均时长统计的有效条数;
completedCount 本月(TARGET_DATE)已出场(EXIT_TIME IS NOT NULL)的数量;
totalCount 本月(TARGET_DATE)预约总数量。
-->
<select id="queryMonthTaskStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO">
SELECT
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
THEN (EXIT_TIME - ENTRY_TIME) * 24
END) AS avgDurationHours,
SUM(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
THEN 1 ELSE 0 END) AS durationCount,
SUM(CASE WHEN EXIT_TIME IS NOT NULL
AND TARGET_DATE IS NOT NULL
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
THEN 1 ELSE 0 END) AS completedCount,
SUM(CASE WHEN TARGET_DATE IS NOT NULL
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
THEN 1 ELSE 0 END) AS totalCount
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
</select>
<!-- 今日预约-业务类型统计:按 BUSINESS_NAME(业务类型名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
<!-- 今日预约-业务名称统计:按 BUSINESS_NAME(业务名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
SELECT
BUSINESS_NAME AS businessName,
@@ -152,20 +102,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY 1 DESC
</select>
<!-- 任务类型统计(来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表):
按本月预约车辆数(TARGET_DATE 在当前月)按 BUSINESS_NAME 业务类型分组统计 -->
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
SELECT
BUSINESS_NAME AS businessName,
COUNT(1) AS count
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
WHERE BUSINESS_NAME IS NOT NULL
AND TARGET_DATE IS NOT NULL
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
GROUP BY BUSINESS_NAME
ORDER BY COUNT(1) DESC
</select>
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
SELECT
@@ -26,8 +26,7 @@ import java.io.InputStream;
import java.util.List;
import java.util.Map;
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
@FeignClient(value = "mhd-third-party-service",url = "http://10.102.192.31:8012", configuration = FeignAutoConfiguration.class)
@FeignClient(value = "mhd-third-party-service",url = "http://10.33.0.129:8012", configuration = FeignAutoConfiguration.class)
public interface ThirdPartyServiceFeign {
//查询当前组织所有三方接口信息
@@ -13,16 +13,16 @@ spring:
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010
# server-addr: 127.0.0.1:8848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
#线上正式环境
# server-addr: 10.102.192.105:6848
config:
server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010
# server-addr: 127.0.0.1:8848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
@@ -97,7 +97,6 @@ import com.mhd.system.api.model.LoginUser;
import com.mhd.user.interfaces.dto.addDTO.UserDriverDTO;
import com.mhd.user.interfaces.dto.queryDTO.UserDocumentWarningQueryDTO;
import com.mhd.user.interfaces.dto.updateDTO.UpdateHasDefaultAddressDTO;
import com.mhd.user.interfaces.dto.updateDTO.PasswordChangeDTO;
import com.mhd.user.interfaces.facadeApi.Po.UserDriverCountPo;
import com.mhd.user.interfaces.vo.QueryAllShipperInfoVo;
import lombok.extern.slf4j.Slf4j;
@@ -215,61 +214,6 @@ public class UserApplicationService {
@Autowired
private UserShipperMapper userShipperMapper;
/**
* 修改密码 - 同步 wlhy yms
*/
@Transactional(rollbackFor = Exception.class)
public void changePassword(PasswordChangeDTO passwordChangeDTO) {
// 1. 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Long userId = loginUser.getUserPo().getUserId();
if (userId == null) {
throw new ServiceException("用户未登录");
}
// 2. 查询用户信息
UserPo userPO = userDomainService.selectByUserId(userId);
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(userPO,userEntity);
if (ObjectUtil.isNull(userEntity)) {
throw new ServiceException("用户不存在");
}
// 3. 解密并加密新密码
String salt = userEntity.getUserSalt();
String newPassword = decrypt(passwordChangeDTO.getNewPassword());
String encodedPassword = PasswordUtil.encrypt(userEntity.getUserAccount(), newPassword, salt);
// 4. 更新本地密码
UserDO userDO = new UserDO();
userDO.setUserId(userId);
userDO.setUserPassword(encodedPassword);
userDomainService.updateUser(userDO);
// 5. 同步到网货平台wlhy
try {
userEntity.setUserPassword(encodedPassword);
wlhyDomainService.addOrEditPlatformUser(userEntity);
} catch (Exception e) {
log.warn("同步密码到网货平台失败,但不影响主流程:{}", e.getMessage());
}
// 6. 同步到 YMS 平台
try {
Integer isQueue = userMapper.getOrdIsQueue(userEntity.getOrganizationId());
if (isQueue != null && isQueue == 1) {
userEntity.setUserPassword(newPassword);
ymsDomainService.addOrEditYmsUser(userEntity);
}
} catch (Exception e) {
log.warn("同步密码到 YMS 平台失败,但不影响主流程:{}", e.getMessage());
}
}
/**
* @Description 查询用户列表
* @Author Alex
@@ -2027,11 +1971,6 @@ public class UserApplicationService {
if (StrUtil.isEmpty(userDO.getUserName())) {
userDO.setUserName("用户" + userDO.getUserPhone().substring(userDO.getUserPhone().length() - 4));
}
//密码为空则给默认密码
if (StrUtil.isEmpty(userDO.getUserPassword())) {
String defaultPassword = "Aa123456";
userDO.setUserPassword(PasswordUtil.encrypt(userDO.getUserAccount(), defaultPassword, userDO.getUserSalt()));
}
UserEntity userEntity = userDomainService.addUser(userDO);
//给小程序注册用户分配默认普通用户角色must本组织没有则找上级
userEntity.setUserPassword("Aa123456"); // 三方同步需要密码
@@ -100,7 +100,6 @@ public class UserYmsDomainService {
ymsSysUserDTO.setPhonenumber(userEntity.getUserPhone());
ymsSysUserDTO.setAvatar(userEntity.getAvatar());
ymsSysUserDTO.setUserAccountType(userEntity.getUserAccountType());
ymsSysUserDTO.setPassword(userEntity.getUserPassword());
if (StringUtils.isNotBlank(userEntity.getRoleCode())){
ymsSysUserDTO.setRoleCodes(Arrays.asList(userEntity.getRoleCode().split(",")));
@@ -1,20 +0,0 @@
package com.mhd.user.interfaces.dto.updateDTO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 修改密码 DTO
* @author AI
* @date 2026/09/10
*/
@Data
public class PasswordChangeDTO {
/**
* 新密码
*/
@NotBlank(message = "新密码不能为空")
private String newPassword;
}
@@ -32,7 +32,6 @@ import com.mhd.common.security.annotation.InnerAuth;
import com.mhd.common.security.service.TokenService;
import com.mhd.system.api.model.LoginUser;
import com.mhd.user.interfaces.dto.queryDTO.UserDocumentWarningQueryDTO;
import com.mhd.user.interfaces.dto.updateDTO.PasswordChangeDTO;
import com.mhd.user.interfaces.dto.updateDTO.UpdateHasDefaultAddressDTO;
import com.mhd.user.interfaces.vo.QueryAllShipperInfoVo;
import io.swagger.annotations.Api;
@@ -1038,16 +1037,4 @@ public class UserAPI extends BaseController {
public R<String> finShipperEnterpriseNamedByUserId(@PathVariable("userId") Long userId) {
return R.ok(userApplicationService.finShipperEnterpriseNamedByUserId(userId));
}
/**
* 修改密码 - 同步 wlhy 与 yms
* 根据当前登录用户判断是谁修改,只传新密码,不需要校验旧密码
*/
@Log(title = "用户中台管理 - 修改密码", description ="修改当前登录用户密码",businessType = BusinessType.UPDATE)
@ApiOperation("修改密码")
@PostMapping("/changePassword")
public AjaxResult changePassword(@RequestBody PasswordChangeDTO passwordChangeDTO) {
userApplicationService.changePassword(passwordChangeDTO);
return AjaxResult.success();
}
}
@@ -18,15 +18,15 @@ spring:
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
# server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
config:
server-addr: 127.0.0.1:8848
# server-addr: 127.0.0.1:8848
# server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
@@ -49,8 +49,4 @@ feign:
readTimeout: 120000
mhd-third-party-service:
connectTimeout: 10000
readTimeout: 120000
#wechat:
# miniapp:
# appId: wxc9dd2810a77e4e30
# appSecret: 9354ff1215a82785ef14f2355fbf2185
readTimeout: 120000
@@ -0,0 +1,58 @@
package com.mhd.oms.application.service;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationStockInOrderMapper;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.domain.WarehouseFeignPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 仓库信息获取(带本地兜底): 下发/下单冻结/保存等流程原先直接 Feign system 服务取仓库信息,
* system 服务未启动/降级/返回非200时整个流程被"获取仓库信息失败"阻断
* 本组件统一收口: 优先 Feign, 失败时回退本地跨库直查 "NGWL_TEST_SYSTEM".WAREHOUSE( Feign 同库同表, OMS 库账号可读),
* 两侧都取不到才抛错并带出 Feign 真实返回原因
*
* @date 2026/9/11
*/
@Slf4j
@Service
public class WarehouseInfoApplicationService {
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private ReservationStockInOrderMapper reservationStockInOrderMapper;
/**
* 获取仓库信息: Feign 优先, 失败走本地兜底; 两边都取不到抛 ServiceException
*
* @param warehouseId 仓库id
* @return 仓库信息(含编码/名称/单号生成规则/库存锁定模式等)
*/
public WarehouseFeignPO getWarehouseInfo(Long warehouseId) {
if (warehouseId == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = null;
try {
ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId);
} catch (Exception e) {
log.warn("获取仓库信息Feign调用异常, 走本地兜底查询, warehouseId={}, error={}", warehouseId, e.getMessage());
}
if (ajaxResult != null && "200".equals(String.valueOf(ajaxResult.get("code"))) && ajaxResult.get("data") != null) {
return com.alibaba.fastjson.JSON.parseObject(
com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
}
String remoteMsg = ajaxResult == null ? "Feign调用异常" : String.valueOf(ajaxResult.get("msg"));
log.warn("获取仓库信息Feign失败(返回: {}), 走本地兜底查询, warehouseId={}", remoteMsg, warehouseId);
WarehouseFeignPO local = reservationStockInOrderMapper.getWarehouseInfoFallback(warehouseId);
if (local == null) {
throw new ServiceException("获取仓库信息失败(Feign返回:" + remoteMsg + "), 且本地未查到仓库[warehouseId="
+ warehouseId + "], 请检查仓库是否存在/已启用");
}
return local;
}
}
@@ -1,554 +0,0 @@
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);
}
}
}
@@ -46,6 +46,9 @@ public class OutEntrustOrderApplicationService {
@Resource
private SystemServiceFeign systemServiceFeign;
@Resource
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
@Resource
private WmsServiceFeign wmsServiceFeign;
@@ -352,14 +355,10 @@ public class OutEntrustOrderApplicationService {
}
/**
* 仓库信息校验并回填编码/名称
* 仓库信息校验并回填编码/名称 (Feign失败走本地跨库兜底)
*/
private void setWarehouseInfo(OutEntrustOrderDO outEntrustOrderDO) {
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(outEntrustOrderDO.getWarehouseId());
if (ajaxResult == null || !"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("获取仓库信息失败,请检查仓库是否有效");
}
WarehouseFeignPO warehouseFeignPO = JSONUtil.toBean(JSONUtil.toJsonStr(ajaxResult.get("data")), WarehouseFeignPO.class);
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(outEntrustOrderDO.getWarehouseId());
if (warehouseFeignPO == null || Objects.isNull(warehouseFeignPO.getWarehouseId())) {
throw new ServiceException("仓库不存在,请重新选择");
}
@@ -659,7 +659,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Date documentDate;
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回 3-调整待审核")
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回")
private Long reviewStatus;
@ApiModelProperty("审核时间")
@@ -825,7 +825,4 @@ public class BusinessDocumentOrder extends BaseVOEntity{
@ApiModelProperty("车次")
@Excel(name = "车次")
private String shuttleNo;
@ApiModelProperty("业务单调整状态 0-无 1-调整待审核 2-调整驳回 3-调整已通过")
private Integer adjustStatus;
}
@@ -39,8 +39,8 @@ public interface BusinessDocumentOrderMapper extends BaseMapper<BusinessDocument
String getPushVerifyByOrgId(@Param("organizationId") Long organizationId);
/**
* 统计指定日期前缀(yyMMdd)下已生成的新格式业务单号数量
* 统计新格式(长度<=12)过滤历史16位旧数据保证序号每日从001正确累计
* 查询指定日期前缀(yyMMdd)下已生成的新格式业务单号列表
* 新格式(长度<=12)过滤历史16位旧数据供取号器解析当日最大序号
*/
int countByGoodsNumberPrefix(@Param("prefix") String prefix);
List<String> selectGoodsNumbersByPrefix(@Param("prefix") String prefix);
}
@@ -237,11 +237,8 @@ public class BusinessDocumentOrderImpl extends ServiceImpl<BusinessDocumentOrder
subOrder.setRecipientName(user.getUserName());
//生成子单货源单号yyMMdd + 当日顺序号
String orderCode = goodsNumberGenerator.generateUniqueGoodsNumber(subOrder.getDocumentDate());
subOrder.setGoodsNumber(orderCode);
businessDocumentOrderMapper.insert(subOrder);
//生成子单货源单号yyMMdd + 当日顺序号并落库, 撞唯一索引自动重新取号重试
goodsNumberGenerator.insertWithUniqueGoodsNumber(subOrder);
subOrderCount++; // 增加子单计数
// 保存子单的地址信息到BUSINESS_DOCUMENT_ADDRESS_MULTI表
@@ -285,24 +285,9 @@ public class BusinessDocumentOrderDomainService {
}
}
//生成货源单号yyMMdd + 当日顺序号每日重置
String orderCode = goodsNumberGenerator.generateUniqueGoodsNumber(tmsOrder.getDocumentDate());
tmsOrder.setGoodsNumber(orderCode);
ReservationStockOutOrder reservationStockOutOrder = reservationStockOutOrderMapper.selectOne(new LambdaQueryWrapper<ReservationStockOutOrder>()
.eq(ReservationStockOutOrder::getOutOrderNumber, tmsOrder.getInOrderNumber())
.eq(ReservationStockOutOrder::getDelFlag, 1));
if (reservationStockOutOrder != null){
reservationStockOutOrder.setBusinessNumber(tmsOrder.getGoodsNumber());
reservationStockOutOrderMapper.updateById(reservationStockOutOrder);
}
ReservationStockInOrder reservationStockInOrder = reservationStockInOrderMapper.selectOne(new LambdaQueryWrapper<ReservationStockInOrder>()
.eq(ReservationStockInOrder::getInOrderNumber, tmsOrder.getInOrderNumber())
.eq(ReservationStockInOrder::getDelFlag, 1));
if (reservationStockInOrder != null){
reservationStockInOrder.setBusinessNumber(tmsOrder.getGoodsNumber());
reservationStockInOrderMapper.updateById(reservationStockInOrder);
}
//生成货源单号并落库见下方 insertWithUniqueGoodsNumber:
//取号与插单合并为原子重试(撞goods_number唯一索引自动重新取号),
//出库/入库业务单的单号回填也移至插单成功之后,避免插单失败留下脏回填
List<BusinessDocumentAddressMultiDTO> loadingAddressList = businessDocumentOrderDO.getLoadingAddressList();//装货地信息集合
List<BusinessDocumentAddressMultiDTO> unloadAddressList = businessDocumentOrderDO.getUnloadAddressList();//卸货地信息集合
@@ -426,7 +411,24 @@ public class BusinessDocumentOrderDomainService {
//一天后
tmsOrder.setDocumentDate(businessDocumentOrderDO.getDocumentDate());
boolean istrue = businessDocumentOrderMapper.insert(tmsOrder) > 0;
//生成货源单号yyMMdd + 当日顺序号每日重置并落库, 撞唯一索引自动重新取号重试
boolean istrue = goodsNumberGenerator.insertWithUniqueGoodsNumber(tmsOrder);
//落库成功后将运输业务单号回填至关联的出库/入库业务单
ReservationStockOutOrder reservationStockOutOrder = reservationStockOutOrderMapper.selectOne(new LambdaQueryWrapper<ReservationStockOutOrder>()
.eq(ReservationStockOutOrder::getOutOrderNumber, tmsOrder.getInOrderNumber())
.eq(ReservationStockOutOrder::getDelFlag, 1));
if (reservationStockOutOrder != null){
reservationStockOutOrder.setBusinessNumber(tmsOrder.getGoodsNumber());
reservationStockOutOrderMapper.updateById(reservationStockOutOrder);
}
ReservationStockInOrder reservationStockInOrder = reservationStockInOrderMapper.selectOne(new LambdaQueryWrapper<ReservationStockInOrder>()
.eq(ReservationStockInOrder::getInOrderNumber, tmsOrder.getInOrderNumber())
.eq(ReservationStockInOrder::getDelFlag, 1));
if (reservationStockInOrder != null){
reservationStockInOrder.setBusinessNumber(tmsOrder.getGoodsNumber());
reservationStockInOrderMapper.updateById(reservationStockInOrder);
}
if (hasDetails) {
for (BusinessDeliveryDetailsLinkDTO businessDeliveryDetailsLinkDTO : businessDeliveryDetailsLinkDTOList) {
@@ -5,23 +5,44 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 业务单据订单(goodsNumber)单号生成器
* 规则: yyMMdd(取自单据日期) + 当日顺序号(每日重置, 3位起步, 超999自动扩位)
* 示例: 2608040012608049992608041000
*
* 唯一性保障(不依赖唯一索引, 三层防线):
* 1) 取号: 当日已生成单号 MAX+1 作为基线 + 候选号存在性校验后移收敛
* (对齐入库单号修复先例 ReservationStockInOrderDomainService#generateReserveOrderNumber)
* 2) 落库: 按日期前缀分段的JVM锁串行化"取号+插单", 消除本实例内并发审核/
* 批量取号的check-then-act竞态(多实例部署时本层只覆盖各自实例)
* 3) 自检自愈: 插单后立即校验同号数量, >1 说明与并发插入撞号, 给本单重新
* 取号改号, 兜住跨实例残余竞态
* 若日后补建goods_number唯一索引( sql/20260906_oms_business_goods_number_unique.sql),
* 撞号将抛DuplicateKeyException由重试逻辑接住, 与上述防线叠加互不冲突
*/
@Slf4j
@Component
public class GoodsNumberGenerator {
private static final int MAX_RETRY = 100;
/**
* 取号+插单分段锁: 按单号日期前缀(yyMMdd)分段, 同日串行跨日并行,
* 锁对象常驻(每日新增1个, 增量可忽略)
*/
private static final Map<String, Object> LOCK_STRIPES = new ConcurrentHashMap<>();
@Autowired
private BusinessDocumentOrderMapper businessDocumentOrderMapper;
@@ -33,8 +54,21 @@ public class GoodsNumberGenerator {
Date date = (documentDate == null) ? new Date() : documentDate;
String datePart = DateUtil.format(date, "yyMMdd");
// count 只查一次作为序号基线
long seq = (long) businessDocumentOrderMapper.countByGoodsNumberPrefix(datePart) + 1;
// 当日已生成单号的最大序号作为基线(MAX+1而非COUNT+1, 防脏数据/序号错位导致回退复用)
List<String> existNumbers = businessDocumentOrderMapper.selectGoodsNumbersByPrefix(datePart);
long seq = 0;
for (String existNumber : existNumbers) {
if (existNumber == null || existNumber.length() <= datePart.length()) {
continue;
}
String numStr = existNumber.substring(datePart.length());
if (!numStr.matches("\\d+")) {
continue; // 防脏数据(非纯数字后缀)导致解析失败
}
seq = Math.max(seq, Long.parseLong(numStr));
}
seq = seq + 1;
int retryCount = 0;
while (retryCount < MAX_RETRY) {
String orderCode = datePart + String.format("%03d", seq);
@@ -46,8 +80,60 @@ public class GoodsNumberGenerator {
if (CollectionUtils.isEmpty(exist)) {
return orderCode;
}
seq++; // 关键查重失败序号往后递增找空位而不是重新count
seq++; // 关键查重失败序号往后递增找空位而不是重新取基线
}
throw new ServiceException("生成唯一业务单号失败,已达到最大重试次数:" + MAX_RETRY);
}
}
/**
* 生成唯一业务单号并落库: JVM分段锁内完成"取号+插单",
* 插入撞goods_number唯一索引时自动重新取号重试(索引为可选兜底),
* 插单成功后自检同号并自愈改号
* 供业务单创建入口(手动/审核新增审核拆单预约确认)统一使用
* @return 是否插入成功(mapper.insert结果)
*/
public boolean insertWithUniqueGoodsNumber(BusinessDocumentOrder order) {
Date date = (order.getDocumentDate() == null) ? new Date() : order.getDocumentDate();
String lockKey = DateUtil.format(date, "yyMMdd");
synchronized (LOCK_STRIPES.computeIfAbsent(lockKey, k -> new Object())) {
int retryCount = 0;
while (retryCount < MAX_RETRY) {
retryCount++;
order.setGoodsNumber(generateUniqueGoodsNumber(order.getDocumentDate()));
try {
boolean inserted = businessDocumentOrderMapper.insert(order) > 0;
// 插单后自检自愈: 无唯一索引时跨实例并发窗口内的撞号双方都能落库,
// 同号数量>1说明本单撞号, 给本单重新取号改号, 防止单号重复扩散
healIfDuplicated(order);
return inserted;
} catch (DuplicateKeyException e) {
// 已建唯一索引时的兜底: 仅业务单号撞唯一索引时重试, 其他唯一约束冲突原样抛出
String message = e.getMessage();
if (message == null || !message.toLowerCase().contains("goods_number")) {
throw e;
}
log.warn("业务单号[{}]撞号, 自动重新取号重试(第{}次): {}", order.getGoodsNumber(), retryCount, message);
}
}
throw new ServiceException("生成唯一业务单号失败,已达到最大重试次数:" + MAX_RETRY);
}
}
/**
* 插单后自检自愈: 查同号数量, >1 说明有并发插入撞号(本单为后插入方),
* 保持先落库单据单号不变, 重新取号给本单改号
*/
private void healIfDuplicated(BusinessDocumentOrder order) {
List<BusinessDocumentOrder> sameNumber = businessDocumentOrderMapper.selectList(
new QueryWrapper<BusinessDocumentOrder>().eq("goods_number", order.getGoodsNumber())
);
if (sameNumber != null && sameNumber.size() > 1) {
String oldNumber = order.getGoodsNumber();
String newNumber = generateUniqueGoodsNumber(order.getDocumentDate());
order.setGoodsNumber(newNumber);
businessDocumentOrderMapper.updateById(order);
log.warn("业务单号[{}]与并发插入撞号(无唯一索引兜底), 已自愈改号为[{}], orderId={}",
oldNumber, newNumber, order.getId());
}
}
}
@@ -1,93 +0,0 @@
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;
}
@@ -1,12 +0,0 @@
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> {
}
@@ -1,173 +0,0 @@
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;
}
@@ -1,12 +0,0 @@
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> {
}
@@ -501,6 +501,6 @@ public class ExecutionInMaterialDetailPO extends ExecutionStockInOrderBasePO {
private BigDecimal insureAmount;
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
@Excel(name = "货物类型")
@Excel(name = "货物类型", readConverterExp = "0=物料,1=半成品,2=成品")
private Integer goodsType;
}
@@ -1,5 +1,7 @@
package com.mhd.oms.domain.executionInMaterialDetail.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -15,21 +17,34 @@ import java.util.Date;
public class ExecutionInMaterialDetailWithOrderPO extends ExecutionInMaterialDetailPO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("入库单状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭")
@ApiModelProperty("入库单流转状态(参考): 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭")
private Integer inOrderStatus;
@ApiModelProperty("入库单展示状态: 0-已创建 2-已审核 3-已驳回 4-已入库(WMS回写status=5时同步/推送创建时置4,前端状态列绑定此字段)")
@Excel(name = "单据状态", readConverterExp = "0=已创建,2=已审核,3=已驳回,4=已入库")
private Integer issueStatus;
@ApiModelProperty("货物种类(物料分类名称,多个逗号分隔)")
@Excel(name = "货物种类")
private String materialClassifyName;
@ApiModelProperty("入库单审核状态: 1-未审核 2-审核不通过 3-审核通过")
@Excel(name = "入库单审核状态: 1-未审核 2-审核不通过 3-审核通过")
private Integer inOrderAuditStatus;
@ApiModelProperty("货主ID")
private Long orderShipperId;
@ApiModelProperty("货主编码")
@Excel(name = "货主编码")
private String orderShipperCode;
@ApiModelProperty("货主名称")
@Excel(name = "货主名称")
private String orderShipperName;
@ApiModelProperty("入库日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "入仓日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date warehouseDate;
}
@@ -45,6 +45,12 @@ public class ExecutionInMaterialDetailQueryDTO extends BaseVOEntity {
@ApiModelProperty("入库单类型编码")
private String inOrderTypeCode;
@ApiModelProperty("入库单类型编码(与inOrderTypeCode同义)")
private String orderTypeCode;
@ApiModelProperty("入库单类型名称(模糊查询)")
private String orderTypeName;
@ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭")
private Integer inStatus;
@@ -66,4 +72,10 @@ public class ExecutionInMaterialDetailQueryDTO extends BaseVOEntity {
@ApiModelProperty("物料名称")
private String materialName;
@ApiModelProperty("实际入仓日期 开始(yyyy-MM-dd,为空按建档时间兜底)")
private String warehouseDateStart;
@ApiModelProperty("实际入仓日期 结束(yyyy-MM-dd,为空按建档时间兜底)")
private String warehouseDateEnd;
}
@@ -78,6 +78,12 @@ public class QueryOrderOverStockDO extends BaseVOEntity {
@Excel(name = "入库单类型编码")
private String inOrderTypeCode;
@ApiModelProperty("入库单类型编码(与inOrderTypeCode同义)")
private String orderTypeCode;
@ApiModelProperty("入库单类型名称")
private String orderTypeName;
@ApiModelProperty("入库单类型名称")
@Excel(name = "入库单类型名称")
private String inOrderTypeName;
@@ -137,4 +143,10 @@ public class QueryOrderOverStockDO extends BaseVOEntity {
@ApiModelProperty("越库单状态 0:无状态 1:处理中 2:越库完成")
@Excel(name = "越库单状态 0:无状态 1:处理中 2:越库完成")
private Integer overStockStatus;
@ApiModelProperty("实际入仓日期 开始(yyyy-MM-dd,为空按建档时间兜底)")
private String warehouseDateStart;
@ApiModelProperty("实际入仓日期 结束(yyyy-MM-dd,为空按建档时间兜底)")
private String warehouseDateEnd;
}
@@ -85,4 +85,21 @@ public class ExecutionInMaterialDetailApplicationService {
return inMaterialDetailDomainService.queryInOrderDetailList(queryOrderOverStockDO);
}
/**
* 入库明细导出全字段口径同 queryInOrderDetailList不分页
*/
public List<ExecutionInMaterialDetailWithOrderPO> exportInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) {
List<ExecutionInMaterialDetailWithOrderPO> list = queryInOrderDetailList(queryOrderOverStockDO);
// 货物种类=挂载分类的父级分类名称material_classify_name为分类路径("食品,饮料")取倒数第二段
// 仅一级分类(无父级)时取自身名称
for (ExecutionInMaterialDetailWithOrderPO po : list) {
String names = po.getMaterialClassifyName();
if (names != null && names.contains(",")) {
String[] parts = names.split(",");
po.setMaterialClassifyName(parts[parts.length - 2].trim());
}
}
return list;
}
}
@@ -518,4 +518,7 @@ public class ExecutionOutMaterialDetail extends BaseVOEntity {
private String inLineNumGw;
private String opWhLocGw;
private String warehouseGw;
}
@ApiModelProperty("反审标记: 0-无 1-已反审(业务单反审时软删del_flag=2并打标记)")
private Integer reverseFlag;
}
@@ -1,6 +1,7 @@
package com.mhd.oms.domain.executionOutMaterialDetail.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@@ -18,34 +19,49 @@ import java.util.Date;
public class ExecutionOutMaterialDetailWithOrderPO extends ExecutionOutMaterialDetailPO {
private static final long serialVersionUID = 1L;
@ApiModelProperty("出库单状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭")
@ApiModelProperty("出库单流转状态(参考): 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭 12-已复核 13-已交接;WMS出库完成不回写此字段")
private Integer outOrderStatus;
@ApiModelProperty("出库单展示状态: 0-已创建 2-已审核 3-已驳回 4-已出库(WMS出库完成/推送创建时回写,前端状态列绑定此字段)")
@Excel(name = "单据状态", readConverterExp = "0=已创建,2=已审核,3=已驳回,4=已出库")
private Integer issueStatus;
@ApiModelProperty("出库单审核状态: 1-未审核 2-审核不通过 3-审核通过")
@Excel(name = "出库单审核状态: 1-未审核 2-审核不通过 3-审核通过")
private Integer outOrderAuditStatus;
@ApiModelProperty("货主ID")
private Long orderShipperId;
@ApiModelProperty("货主编码")
@Excel(name = "货主编码")
private String orderShipperCode;
@ApiModelProperty("货主名称")
@Excel(name = "货主名称")
private String orderShipperName;
@ApiModelProperty("出仓日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "出仓日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date orderOutboundDate;
@ApiModelProperty("出库时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "出库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date orderOutboundTime;
@ApiModelProperty("保额")
@Excel(name = "保额")
private BigDecimal insureAmount;
@ApiModelProperty("货物类型:0-物料 1-半成品 2-成品")
@Excel(name = "货物类型", readConverterExp = "0=物料,1=半成品,2=成品")
private Integer goodsType;
@ApiModelProperty("货物种类(物料分类名称,多个逗号分隔)")
@Excel(name = "货物种类")
private String materialClassifyName;
}
@@ -45,6 +45,12 @@ public class ExecutionOutMaterialDetailQueryDTO extends BaseVOEntity {
@ApiModelProperty("出库单类型编码")
private String outOrderTypeCode;
@ApiModelProperty("出库单类型编码(与outOrderTypeCode同义)")
private String orderTypeCode;
@ApiModelProperty("出库单类型名称(模糊查询)")
private String orderTypeName;
@ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭")
private Integer outStatus;
@@ -66,4 +72,10 @@ public class ExecutionOutMaterialDetailQueryDTO extends BaseVOEntity {
@ApiModelProperty("物料名称")
private String materialName;
@ApiModelProperty("实际出仓日期 开始(yyyy-MM-dd,为空按建档时间兜底)")
private String outboundDateStart;
@ApiModelProperty("实际出仓日期 结束(yyyy-MM-dd,为空按建档时间兜底)")
private String outboundDateEnd;
}
@@ -459,4 +459,21 @@ public class ExecutionStockInOrder extends BaseVOEntity {
@ApiModelProperty("通知单备注")
private String noticeRemark;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -482,4 +482,21 @@ public class ExecutionStockInOrderPO extends BaseVOEntity {
private String khdm;
@ApiModelProperty("通知单备注")
private String noticeRemark;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -513,4 +513,21 @@ public class ExecutionStockInOrderDO extends BaseVOEntity {
private String businessPriceWay;
@ApiModelProperty("通知单备注")
private String noticeRemark;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -510,4 +510,21 @@ public class ExecutionStockInOrderDTO extends ExecutionStockInOrderBaseDTO {
private String businessPriceWay;
@ApiModelProperty("通知单备注")
private String noticeRemark;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -263,7 +263,16 @@ public class ExecutionStockInOrderApplicationService {
*/
public ExecutionStockInOrderPO getInfo(Long inOrderId)
{
ExecutionStockInOrderPO info = stockInOrderDomainService.getInfo(inOrderId);
return getInfo(inOrderId, false);
}
/**
* 获取入库执行单详情getReverseAuditInfo 归档详情复用
* @param archive true-查询已反审tab 归档数据
*/
public ExecutionStockInOrderPO getInfo(Long inOrderId, boolean archive)
{
ExecutionStockInOrderPO info = stockInOrderDomainService.getInfo(inOrderId, archive);
String userNcCode = reservationStockInOrderMapper.getUserNcCode(info.getShipperId());
info.setKhdm(userNcCode);
List<ExecutionInMaterialDetailPO> materialDetailList = info.getMaterialDetailList();
@@ -276,6 +285,14 @@ public class ExecutionStockInOrderApplicationService {
return info;
}
/**
* 查询入库执行单已反审tab 归档详情已软删+已反审标记的数据含软删明细
*/
public ExecutionStockInOrderPO getReverseAuditInfo(Long inOrderId)
{
return getInfo(inOrderId, true);
}
/**
@@ -314,14 +314,31 @@ public class ExecutionStockInOrderDomainService {
* 获取入库单详细信息
*/
public ExecutionStockInOrderPO getInfo(Long inOrderId)
{
return getInfo(inOrderId, false);
}
/**
* 获取入库执行单详情
* @param archive true-查询已反审tab 归档数据主单须为已软删+已反审标记明细放行软删行
*/
public ExecutionStockInOrderPO getInfo(Long inOrderId, boolean archive)
{
ExecutionStockInOrderPO stockInOrderPO = stockInOrderService.getInfo(inOrderId);
if (archive && (stockInOrderPO.getDelFlag() == null || stockInOrderPO.getDelFlag() != 2
|| !Integer.valueOf(1).equals(stockInOrderPO.getReverseAuditStatus()))) {
throw new ServiceException("入库执行单非已反审归档数据,无法查看归档详情");
}
ExecutionInMaterialDetailDO inMaterialDetailDO = new ExecutionInMaterialDetailDO();
String inOrderNumber = stockInOrderPO.getInOrderNumber();
List<BusinessDocumentOrder> businessDocumentOrders = businessDocumentOrderMapper.selectList(new LambdaQueryWrapper<BusinessDocumentOrder>().eq(BusinessDocumentOrder::getInOrderNumber, inOrderNumber).notIn(BusinessDocumentOrder::getOrderStatus,4,5));
stockInOrderPO.setBusinessDocumentOrderDOList(businessDocumentOrders);
inMaterialDetailDO.setInOrderNumber(inOrderNumber);
inMaterialDetailDO.setLevel(1);
if (archive) {
//归档明细已随主单软删(del_flag=2)放行软删明细行
inMaterialDetailDO.setDelFlag(2);
}
List<ExecutionInMaterialDetailPO> inMaterialDetailPOList = materialDetailService.queryList(inMaterialDetailDO);
// 先通过入库单号查询收货单列表
@@ -516,4 +516,7 @@ public class ExecutionStockOutOrder extends BaseVOEntity {
@ApiModelProperty("折扣")
private BigDecimal discount;
}
@ApiModelProperty("反审标记: 0-无 1-已反审(业务单反审时软删del_flag=2并打标记)")
private Integer reverseFlag;
}
@@ -29,6 +29,8 @@ public class ExecutionStockOutOrderPO extends BaseVOEntity {
@ApiModelProperty("出库单id")
private Long outOrderId;
@ApiModelProperty("反审标记: 1-已反审(反审软删归档, 【已反审】tab按 delFlag=2+reverseFlag=1 查询)")
private Integer reverseFlag;
@ApiModelProperty("总价")
@Excel(name = "总价")
private BigDecimal amount;
@@ -29,6 +29,9 @@ public class ExecutionStockOutOrderDO extends BaseVOEntity {
@ApiModelProperty("出库单id")
private Long outOrderId;
@ApiModelProperty("反审标记查询: 1-已反审(与delFlag=2成对传, 查【已反审】tab归档数据)")
private Integer reverseFlag;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@@ -27,6 +27,9 @@ public class ExecutionStockOutOrderDTO extends ExecutionStockOutOrderBaseDTO {
@ApiModelProperty("出库单id")
private Long outOrderId;
@ApiModelProperty("反审标记查询: 1-已反审(与delFlag=2成对传, 查【已反审】tab归档数据)")
private Integer reverseFlag;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@@ -66,6 +66,8 @@ import java.util.stream.Collectors;
public class ExecutionStockOutOrderApplicationService {
@Autowired
private ExecutionStockOutOrderDomainService stockOutOrderDomainService;
@Autowired
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
// @Autowired
// private ExecutionOutMaterialDetailDomainService outMaterialDetailDomainService;
// @Autowired
@@ -862,11 +864,8 @@ public class ExecutionStockOutOrderApplicationService {
if (stockOutOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockOutOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败");
}
WarehouseFeignPO warehouseFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
// Feign失败走本地跨库兜底, 避免保存被"获取仓库信息失败"阻断
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(stockOutOrderDO.getWarehouseId());
stockOutOrderDO.setWarehouseCode(warehouseFeignPO.getWarehouseCode());
stockOutOrderDO.setWarehouseName(warehouseFeignPO.getWarehouseName());
}
@@ -71,6 +71,8 @@ public class ExecutionStockOutOrderDomainService {
@Autowired
private IExecutionStockOutOrderService stockOutOrderService;
@Autowired
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
@Autowired
private IExecutionOutMaterialDetailService outMaterialDetailService;
@Autowired
private IReservationDeliveryDetailsLinkService deliveryDetailsLinkService;
@@ -148,14 +150,9 @@ public class ExecutionStockOutOrderDomainService {
public Boolean insert(ExecutionStockOutOrderDO stockOutOrderDO) {
//建单校验明细数量必须大于00数量单下发WMS后自动分配必失败出库单会卡死在已审核状态
validateMaterialDetailQuantity(stockOutOrderDO.getMaterialDetailList());
//设置单号
//设置单号(仓库信息: Feign优先, system服务失败/降级时本地跨库兜底)
Long warehouseId = stockOutOrderDO.getWarehouseId();
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId);
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("获取仓库信息失败");
}
//仓库信息
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(warehouseId);
String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule();
String prefix = warehouseFeignPO.getOutOrderNoPrefix();
if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) {
@@ -218,14 +215,9 @@ public class ExecutionStockOutOrderDomainService {
@Transactional(rollbackFor = Exception.class)
public Boolean batchInsert(List<ExecutionStockOutOrderDO> stockOutOrderDOList) {
for (ExecutionStockOutOrderDO stockOutOrderDO : stockOutOrderDOList){
//设置单号
//设置单号(仓库信息: Feign优先, system服务失败/降级时本地跨库兜底)
Long warehouseId = stockOutOrderDO.getWarehouseId();
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId);
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("获取仓库信息失败");
}
//仓库信息
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(warehouseId);
String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule();
String prefix = warehouseFeignPO.getOutOrderNoPrefix();
if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) {
@@ -542,7 +534,12 @@ public class ExecutionStockOutOrderDomainService {
stockOutOrder.setOrganizationId(orgId);
stockOutOrder.setOrganizationName(orgName);
stockOutOrder.setTopOrganizationId(topOrgId);
wmsServiceFeign.omsOutOrderAdd(stockOutOrder);
//单头/配送明细推送同样校验返回值: 降级吞掉会残留"有单无明细"等半截单
AjaxResult orderAddResult = wmsServiceFeign.omsOutOrderAdd(stockOutOrder);
if (orderAddResult == null || !"200".equals(String.valueOf(orderAddResult.get("code")))) {
throw new ServiceException("出库单[" + currentOrderNumber + "]WMS出库单推送失败:"
+ (orderAddResult == null ? "WMS服务不可用或已降级" : orderAddResult.get("msg")));
}
List<ReservationDeliveryDetailsLink> list = deliveryDetailsLinkService.list(new QueryWrapper<ReservationDeliveryDetailsLink>().lambda().eq(ReservationDeliveryDetailsLink::getOrderNumber, byId.getOutOrderNumber()));
List<DeliveryDetailsLink> deliveryDetailsLinkList = new ArrayList<>();
@@ -552,7 +549,11 @@ public class ExecutionStockOutOrderDomainService {
deliveryDetailsLink.setOmsId(reservationDeliveryDetailsLink.getId());
deliveryDetailsLinkList.add(deliveryDetailsLink);
}
wmsServiceFeign.omsOutOrderAddDeliveryDetailsLink(deliveryDetailsLinkList);
AjaxResult linkAddResult = wmsServiceFeign.omsOutOrderAddDeliveryDetailsLink(deliveryDetailsLinkList);
if (linkAddResult == null || !"200".equals(String.valueOf(linkAddResult.get("code")))) {
throw new ServiceException("出库单[" + currentOrderNumber + "]WMS配送明细推送失败:"
+ (linkAddResult == null ? "WMS服务不可用或已降级" : linkAddResult.get("msg")));
}
String inOrderNumber = stockOutOrder.getOutOrderNumber();
@@ -566,7 +567,12 @@ public class ExecutionStockOutOrderDomainService {
outMaterialDetail.setTopOrganizationId(topOrgId);
outMaterialDetailList.add(outMaterialDetail);
}
wmsServiceFeign.omsOutOrderAddDetail(outMaterialDetailList);
//明细推送必须校验返回值: 失败被降级吞掉时WMS会残留"有单无明细"的出库单, 自动分配报"可用库存为0"难定位
AjaxResult detailAddResult = wmsServiceFeign.omsOutOrderAddDetail(outMaterialDetailList);
if (detailAddResult == null || !"200".equals(String.valueOf(detailAddResult.get("code")))) {
throw new ServiceException("出库单[" + currentOrderNumber + "]WMS出库明细推送失败:"
+ (detailAddResult == null ? "WMS服务不可用或已降级" : detailAddResult.get("msg")));
}
String outOrderNumber = byId.getOutOrderNumber();
com.mhd.system.api.domain.StockOutOrderDTO stockOutOrderDTO = new com.mhd.system.api.domain.StockOutOrderDTO();
@@ -102,6 +102,12 @@ public class QueryOrderOverStockDO extends BaseVOEntity {
@Excel(name = "出库单类型编码")
private String outOrderTypeCode;
@ApiModelProperty("出库单类型编码(与outOrderTypeCode同义)")
private String orderTypeCode;
@ApiModelProperty("出库单类型名称")
private String orderTypeName;
@ApiModelProperty("出库单类型名称")
@Excel(name = "出库单类型名称")
private String outOrderTypeName;
@@ -137,4 +143,10 @@ public class QueryOrderOverStockDO extends BaseVOEntity {
@ApiModelProperty("越库单状态 0:无状态 1:处理中 2:越库完成")
@Excel(name = "越库单状态 0:无状态 1:处理中 2:越库完成")
private Integer overStockStatus;
@ApiModelProperty("实际出仓日期 开始(yyyy-MM-dd,为空按建档时间兜底)")
private String outboundDateStart;
@ApiModelProperty("实际出仓日期 结束(yyyy-MM-dd,为空按建档时间兜底)")
private String outboundDateEnd;
}
@@ -456,4 +456,21 @@ public class ReservationStockInOrder extends BaseVOEntity {
@ApiModelProperty("业务计价方式")
private String businessPriceWay;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -54,6 +54,13 @@ public interface ReservationStockInOrderMapper extends BaseMapper<ReservationSto
public String getWarehouseName(@Param("id") Long id);
/**
* 本地跨库直查仓库信息(编码/名称/单号生成规则),
* 供下发等流程在 system 服务 Feign 失败/降级时兜底, getWarehouseInfoByWarehouseId Feign 接口同数据源
* 不含 STOCK_LOCK_MODE(冻结功能列, 各环境库结构不一致), 兜底时 stockLockMode null 即默认分配库存冻结模式
*/
public com.mhd.system.api.domain.WarehouseFeignPO getWarehouseInfoFallback(@Param("id") Long id);
List<ReservationStockInOrderPO> queryNoticePrint(ReservationStockInOrderDO stockInOrderDO);
List<ReservationInMaterialDetailPO> queryNoticePrintDetail(ReservationStockInOrderDO stockInOrderDO);
public void updateByTransportationNumber(@Param("transportationNumber") String transportationNumber);
@@ -502,4 +502,21 @@ public class ReservationStockInOrderPO extends BaseVOEntity {
@ApiModelProperty("业务计价方式")
private String businessPriceWay;
private String khdm;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -513,4 +513,21 @@ public class ReservationStockInOrderDO extends BaseVOEntity {
@ApiModelProperty("业务计价方式")
private String businessPriceWay;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -507,4 +507,21 @@ public class ReservationStockInOrderDTO extends ReservationStockInOrderBaseDTO {
@ApiModelProperty("业务计价方式")
private String businessPriceWay;
@ApiModelProperty("反审状态: 0-无 1-已反审")
private Integer reverseAuditStatus;
@ApiModelProperty("反审原因")
private String reverseAuditRemark;
@ApiModelProperty("反审人id")
private Long reverseAuditBy;
@ApiModelProperty("反审人姓名")
private String reverseAuditByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseAuditTime;
}
@@ -282,8 +282,7 @@ public class ReservationStockInOrderApplicationService {
* @return Boolean
*/
public Boolean auditState(ReservationStockInOrderDO stockInOrderDO){
Boolean b = stockInOrderDomainService.auditState(stockInOrderDO);
// List<Long> inOrderIds = stockInOrderDO.getInOrderIds();
Boolean b = stockInOrderDomainService.auditState(stockInOrderDO);// List<Long> inOrderIds = stockInOrderDO.getInOrderIds();
// if (inOrderIds != null && !inOrderIds.isEmpty()) {
// ReservationStockInOrder stockInOrder = reservationStockInOrderMapper.selectById(inOrderIds.get(0));
// Integer needCustomsDeclaration = stockInOrder.getNeedCustomsDeclaration();
@@ -302,6 +301,15 @@ public class ReservationStockInOrderApplicationService {
return b;
}
/**
* 反审入库业务单业务单状态改为已驳回(issueStatus=3)并打已反审标记落入已反审tab
* 入库执行单+明细逻辑删除WMS侧整链回退库存扣减+单据清理+反审异常记录
* W入库单有出库记录时WMS侧拦截已推送关务直接拦截
*/
public Boolean reverseAudit(ReservationStockInOrderDO stockInOrderDO){
return stockInOrderDomainService.reverseAudit(stockInOrderDO);
}
/**
* @description 下发入库单
* @author ZhouGY
@@ -13,6 +13,9 @@ 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.electronicSignature.entity.ElectronicSignature;
import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureMaterialDetailService;
import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureService;
import com.mhd.oms.domain.executionInMaterialDetail.entity.ExecutionInMaterialDetail;
import com.mhd.oms.domain.executionInMaterialDetail.repository.facade.IExecutionInMaterialDetailService;
import com.mhd.oms.domain.executionStockInOrder.entity.ExecutionStockInOrder;
@@ -91,6 +94,10 @@ public class ReservationStockInOrderDomainService {
private ExecutionStockInOrderMapper executionStockInOrderMapper;
@Autowired
private ReserveStockInOrderMapper reserveStockInOrderMapper;
@Autowired
private IElectronicSignatureService electronicSignatureService;
@Autowired
private IElectronicSignatureMaterialDetailService electronicSignatureMaterialDetailService;
/**
* 分页查询入库单列表
@@ -169,6 +176,10 @@ public class ReservationStockInOrderDomainService {
// //统计总体积
// BigDecimal volumeLimit = stockInOrderDO.getMaterialDetailList().stream().map(ReservationInMaterialDetailDO::getVolumeLimit).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
// stockInOrderDO.setVolumeLimit(volumeLimit);
// 订单来源为空时兜底为手动创建导入/预约下发等路径已显式设置不受影响下发执行单时随业务单继承
if (stockInOrderDO.getReservationOrderSource() == null || stockInOrderDO.getReservationOrderSource().isEmpty()) {
stockInOrderDO.setReservationOrderSource("手动创建");
}
stockInOrderService.insert(stockInOrderDO);
return materialDetailService.batchInsert(stockInOrderDO.getInOrderNumber(), stockInOrderDO.getMaterialDetailList());
}
@@ -607,7 +618,6 @@ public class ReservationStockInOrderDomainService {
reservationStockInOrder.setOrderTypeName("普通入库");
reservationStockInOrder.setBusinessType("pu_tong_ru_ku");
}
reservationStockInOrder.setReservationOrderSource("客户预约");
reservationStockInOrder.setWarehouseId(warehouseId);
if (warehouseId == null || warehouseId == 0L){
reservationStockInOrder.setWarehouseId(byId.getWarehouseId());
@@ -767,6 +777,171 @@ public class ReservationStockInOrderDomainService {
}
}
/**
* 反审入库业务单需求已入库/已出库的单子客户通知需要回退的场景单子回退到最原始状态
* 页面状态列按 issueStatus0-已创建 1-进行中 2-已审核 3-已驳回 4-已入库 5-部分完成展示
* 反审条件按 issueStatus 判断进行中(1)/已审核(2)/已入库(4)/部分完成(5)可反审
* 已创建(0)无需反审已驳回(3)可直接编辑已取消/已关闭(status 6/7)兜底拦截
* 反审动作"审核不通过"同语义 + 全链路回退补齐 auditState 审核不通过缺失的下游联动
* <ul>
* <li>业务单状态改为"已驳回"(issueStatus=3)打已反审标记(REVERSE_AUDIT_STATUS=1)落入已反审tab
* 之后可编辑重新审核重新下发生成全新执行单</li>
* <li>入库执行单+物料明细软删(del_flag=2)并打已反审标记执行单已反审tab按
* "已软删+已反审"查询归档数据软删后不出现在正常tab避免归档单被误审核/下发</li>
* <li>清空WMS完成上架跨库回写的完成数据业务单 IN_QUANTITY/STORAGE_TIME明细 INBOUND_ITEMS/TOTAL_NET_WEIGHT</li>
* <li>WMS侧逐执行单回退omsReverseInOrderW入库单有出库记录则拦截按入库单号+动作"分配库存/出库"
* 查库存调整记录&gt;0 库存还原扣减 W入库单/W收货单/W上架单整链软删并打已反审标记
* 数据划归W入库单/W收货单/W上架单已反审tab归档
* 写1条W入库异常反审记录用于记录跟踪</li>
* </ul>
* 已推送关务(pushStatus=3)直接拦截WMS回退幂等反审失败可安全重试
*/
@Transactional(rollbackFor = Exception.class)
public Boolean reverseAudit(ReservationStockInOrderDO stockInOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 获取用户姓名优先从UserPo获取如果为空则使用realname最后使用username作为兜底
String userRealName = loginUser.getUserPo() != null && loginUser.getUserPo().getUserName() != null
? loginUser.getUserPo().getUserName()
: (loginUser.getRealname() != null ? loginUser.getRealname() : loginUser.getUsername());
List<Long> inOrderIds = stockInOrderDO.getInOrderIds();
if (inOrderIds == null || inOrderIds.isEmpty()) {
throw new ServiceException("未选择反审的入库业务单");
}
Date now = new Date();
for (Long inOrderId : inOrderIds) {
ReservationStockInOrder businessOrder = stockInOrderService.getById(inOrderId);
if (businessOrder == null
|| (businessOrder.getDelFlag() != null && businessOrder.getDelFlag() != 1)) {
throw new ServiceException("入库业务单不存在或已被删除,无法反审");
}
String businessNumber = businessOrder.getInOrderNumber();
Integer issueStatus = businessOrder.getIssueStatus();
if (issueStatus == null || issueStatus == 0) {
throw new ServiceException("入库业务单[" + businessNumber + "]为已创建状态,无需反审");
}
if (issueStatus == 3) {
throw new ServiceException("入库业务单[" + businessNumber + "]已驳回,无需反审,可直接编辑后重新提交审核");
}
if (issueStatus != 1 && issueStatus != 2 && issueStatus != 4 && issueStatus != 5) {
throw new ServiceException("入库业务单[" + businessNumber + "]仅进行中/已审核/已入库状态可反审,当前状态值:" + issueStatus);
}
if (businessOrder.getStatus() != null && (businessOrder.getStatus() == 6 || businessOrder.getStatus() == 7)) {
throw new ServiceException("入库业务单[" + businessNumber + "]已取消/已关闭,无法反审");
}
if (businessOrder.getPushStatus() != null && businessOrder.getPushStatus() == 3) {
throw new ServiceException("入库业务单[" + businessNumber + "]已推送关务/NC,无法反审,请先在关务侧处理");
}
//该业务单下全部有效执行单逐张调WMS回退后软删并打已反审标记
List<ExecutionStockInOrder> executionOrders = executionStockInOrderService.list(
new LambdaQueryWrapper<ExecutionStockInOrder>()
.eq(ExecutionStockInOrder::getBusinessInOrderNumber, businessNumber)
.eq(ExecutionStockInOrder::getDelFlag, 1));
for (ExecutionStockInOrder executionOrder : executionOrders) {
String executionNumber = executionOrder.getInOrderNumber();
if (executionOrder.getPushStatus() != null && executionOrder.getPushStatus() == 3) {
throw new ServiceException("执行入库单[" + executionNumber + "]已推送关务/NC,无法反审,请先在关务侧处理");
}
//WMS侧回退对称收货/上架完成链路 WMS StockInOrderDomainService.reverseExecutionOrder
//有出库/库存已被分配时WMS报错此处抛错整体回滚WMS无数据时幂等成功未下发执行单反审
StockInOrder reverseParam = new StockInOrder();
reverseParam.setInOrderNumber(executionNumber);
reverseParam.setRemark("业务单号:" + businessNumber
+ (StringUtils.isNotEmpty(stockInOrderDO.getReverseAuditRemark())
? ",反审原因:" + stockInOrderDO.getReverseAuditRemark() : ""));
//组织三字段WMS幂等跳过分支未下发单反审写反审记录时取不到W入库单需经Feign透传
reverseParam.setOrganizationId(executionOrder.getOrganizationId());
reverseParam.setOrganizationName(executionOrder.getOrganizationName());
reverseParam.setTopOrganizationId(executionOrder.getTopOrganizationId());
reverseParam.setUpdateBy(loginUser.getUserid());
reverseParam.setUpdateByName(userRealName);
AjaxResult reverseResult = wmsServiceFeign.omsReverseInOrder(reverseParam);
if (reverseResult == null || !"200".equals(String.valueOf(reverseResult.get("code")))) {
throw new ServiceException("反审失败:执行入库单[" + executionNumber + "]WMS回退失败:"
+ (reverseResult == null ? "WMS服务不可用或已降级" : reverseResult.get("msg")));
}
//清理下发自动审核生成的待签名电子签名记录signatureStatus=1已签名记录保留作凭证
cancelPendingSignature(executionNumber);
//执行单+物料明细软删(del_flag=2)并打已反审标记
//执行单已反审tab按"已软删+已反审"(del_flag=2 and REVERSE_AUDIT_STATUS=1)查询归档数据
//软删后不出现在正常tab避免归档单被误审核/下发业务单重新下发时生成全新执行单
executionInMaterialDetailService.update(new UpdateWrapper<ExecutionInMaterialDetail>().lambda()
.set(ExecutionInMaterialDetail::getDelFlag, 2)
.set(ExecutionInMaterialDetail::getUpdateBy, loginUser.getUserid())
.set(ExecutionInMaterialDetail::getUpdateByName, userRealName)
.set(ExecutionInMaterialDetail::getUpdateTime, now)
.eq(ExecutionInMaterialDetail::getInOrderNumber, executionNumber)
.eq(ExecutionInMaterialDetail::getDelFlag, 1));
executionStockInOrderService.update(new UpdateWrapper<ExecutionStockInOrder>().lambda()
.set(ExecutionStockInOrder::getDelFlag, 2)
.set(ExecutionStockInOrder::getReverseAuditStatus, 1)
.set(ExecutionStockInOrder::getReverseAuditRemark, stockInOrderDO.getReverseAuditRemark())
.set(ExecutionStockInOrder::getReverseAuditBy, loginUser.getUserid())
.set(ExecutionStockInOrder::getReverseAuditByName, userRealName)
.set(ExecutionStockInOrder::getReverseAuditTime, now)
.set(ExecutionStockInOrder::getUpdateBy, loginUser.getUserid())
.set(ExecutionStockInOrder::getUpdateByName, userRealName)
.set(ExecutionStockInOrder::getUpdateTime, now)
.eq(ExecutionStockInOrder::getInOrderId, executionOrder.getInOrderId())
.eq(ExecutionStockInOrder::getDelFlag, 1));
}
//清空WMS完成上架跨库回写的业务单明细入库数量INBOUND_ITEMS/TOTAL_NET_WEIGHT 上架时按上架量覆写过
materialDetailService.update(new UpdateWrapper<ReservationInMaterialDetail>().lambda()
.set(ReservationInMaterialDetail::getInboundQuantity, BigDecimal.ZERO)
.set(ReservationInMaterialDetail::getTotalNetWeight, BigDecimal.ZERO)
.eq(ReservationInMaterialDetail::getInOrderNumber, businessNumber)
.eq(ReservationInMaterialDetail::getDelFlag, 1));
}
//业务单状态改为"已驳回"与审核不通过同语义+ 已反审标记落入已反审tab + 清空完成回写数据
return stockInOrderService.update(null, new UpdateWrapper<ReservationStockInOrder>().lambda()
.set(ReservationStockInOrder::getIssueStatus, 3)
//清空下发/执行时间前端"是否执行"列按执行时间判断不清会仍显示已执行与取消下发 cancelIssueOrder 同口径
.set(ReservationStockInOrder::getIssueTime, null)
//入库进度状态(1-已创建 2-已审核 3-收货中 4-上架中 5-已入库)首轮"完成上架"会经WMS回传写成5
//不重置的话重新下发时copy给执行单W入库单收货单收货单带着"已完成"状态导致前端不给收货按钮
//重置为1(已创建)与手工新单首次下发链路一致(W入库单/收货单起点=1-待收货)
.set(ReservationStockInOrder::getStatus, 1)
.set(ReservationStockInOrder::getInQuantity, BigDecimal.ZERO)
.set(ReservationStockInOrder::getStorageTime, null)
.set(ReservationStockInOrder::getExecutionInOrderNumber, null)
//反审标记与反审痕迹已反审tab reverseAuditStatus=1 过滤业务单本身不软删保持可编辑重新下发
.set(ReservationStockInOrder::getReverseAuditStatus, 1)
.set(ReservationStockInOrder::getReverseAuditRemark, stockInOrderDO.getReverseAuditRemark())
.set(ReservationStockInOrder::getReverseAuditBy, loginUser.getUserid())
.set(ReservationStockInOrder::getReverseAuditByName, userRealName)
.set(ReservationStockInOrder::getReverseAuditTime, now)
.set(ReservationStockInOrder::getUpdateBy, loginUser.getUserid())
.set(ReservationStockInOrder::getUpdateByName, userRealName)
.set(ReservationStockInOrder::getUpdateTime, now)
.in(ReservationStockInOrder::getInOrderId, inOrderIds));
}
/**
* 反审时清理下发自动审核生成的待签名电子签名记录signatureStatus=1及其明细
* 已签名记录保留作凭证清理失败仅记日志不阻断反审主流程同取消下发
*/
private void cancelPendingSignature(String inOrderNumber) {
try {
List<ElectronicSignature> signatures = electronicSignatureService.list(
new LambdaQueryWrapper<ElectronicSignature>()
.eq(ElectronicSignature::getOrderNumber, inOrderNumber)
.eq(ElectronicSignature::getOrderType, "IN")
.eq(ElectronicSignature::getSignatureStatus, 1)
.eq(ElectronicSignature::getDelFlag, 1));
for (ElectronicSignature signature : signatures) {
electronicSignatureMaterialDetailService.deleteBySignatureId(signature.getSignatureId());
electronicSignatureService.update(new UpdateWrapper<ElectronicSignature>().lambda()
.set(ElectronicSignature::getDelFlag, 2)
.eq(ElectronicSignature::getSignatureId, signature.getSignatureId()));
}
} catch (Exception e) {
log.error("反审清理电子签名记录失败,入库单号:{}", inOrderNumber, e);
}
}
@Transactional(rollbackFor = Exception.class)
public Boolean executeAndIssue(ReservationStockInOrderDO stockInOrderDO) {
// 防重复执行校验 issueOrder 的防重逻辑对齐issueTime 有值表示已下发/执行过
@@ -870,7 +1045,6 @@ public class ReservationStockInOrderDomainService {
reservationStockInOrder.setOrderTypeName("普通入库");
reservationStockInOrder.setBusinessType("pu_tong_ru_ku");
}
reservationStockInOrder.setReservationOrderSource("客户预约");
reservationStockInOrder.setWarehouseId(warehouseId);
// reservationStockInOrder.setOrganizationId(orgId);
// reservationStockInOrder.setOrganizationName(orgName);
@@ -515,4 +515,21 @@ public class ReservationStockOutOrder extends BaseVOEntity {
@ApiModelProperty("折扣")
private BigDecimal discount;
@ApiModelProperty("反审状态: 0-无 1-已反审(反审后status回退为1-已创建,重新审核通过自动复位0)")
private Integer reverseStatus;
@ApiModelProperty("反审人id")
private Long reverseBy;
@ApiModelProperty("反审人姓名")
private String reverseByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseTime;
@ApiModelProperty("反审原因")
private String reverseRemark;
}
@@ -538,4 +538,21 @@ public class ReservationStockOutOrderPO extends BaseVOEntity {
@ApiModelProperty("折扣")
private BigDecimal discount;
@ApiModelProperty("反审状态: 0-无 1-已反审(反审后status回退为1-已创建,重新审核通过自动复位0)")
private Integer reverseStatus;
@ApiModelProperty("反审人id")
private Long reverseBy;
@ApiModelProperty("反审人姓名")
private String reverseByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseTime;
@ApiModelProperty("反审原因")
private String reverseRemark;
}
@@ -591,4 +591,19 @@ public class ReservationStockOutOrderDO extends BaseVOEntity {
@ApiModelProperty("折扣")
private BigDecimal discount;
@ApiModelProperty("反审状态: 0-无 1-已反审(反审后status回退为1-已创建,重新审核通过自动复位0)")
private Integer reverseStatus;
@ApiModelProperty("反审人id")
private Long reverseBy;
@ApiModelProperty("反审人姓名")
private String reverseByName;
@ApiModelProperty("反审时间")
private Date reverseTime;
@ApiModelProperty("反审原因")
private String reverseRemark;
}
@@ -580,4 +580,21 @@ public class ReservationStockOutOrderDTO extends ReservationStockOutOrderBaseDTO
@ApiModelProperty("折扣")
private BigDecimal discount;
@ApiModelProperty("反审状态: 0-无 1-已反审(反审后status回退为1-已创建,重新审核通过自动复位0)")
private Integer reverseStatus;
@ApiModelProperty("反审人id")
private Long reverseBy;
@ApiModelProperty("反审人姓名")
private String reverseByName;
@ApiModelProperty("反审时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date reverseTime;
@ApiModelProperty("反审原因")
private String reverseRemark;
}
@@ -85,6 +85,8 @@ import java.util.stream.Collectors;
public class ReservationStockOutOrderApplicationService {
@Autowired
private ReservationStockOutOrderDomainService stockOutOrderDomainService;
@Autowired
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
// @Autowired
// private ReservationOutMaterialDetailDomainService outMaterialDetailDomainService;
// @Autowired
@@ -881,6 +883,14 @@ public class ReservationStockOutOrderApplicationService {
return stockOutOrderDomainService.cancelIssueOrder(stockOutOrderDO);
}
/**
* @description 反审出库业务单(已出库/已复核单据回退到已创建, WMS库存还原并生成反审异常记录)
* @date 2026/9/8
*/
public Boolean reverseAudit(ReservationStockOutOrderDO stockOutOrderDO){
return stockOutOrderDomainService.reverseAudit(stockOutOrderDO);
}
public Boolean executeAndIssue(ReservationStockOutOrderDO stockOutOrderDO){
return stockOutOrderDomainService.executeAndIssue(stockOutOrderDO);
}
@@ -905,11 +915,8 @@ public class ReservationStockOutOrderApplicationService {
if (stockOutOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockOutOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败");
}
WarehouseFeignPO warehouseFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
// Feign失败走本地跨库兜底, 避免新增/编辑保存被"获取仓库信息失败"阻断
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(stockOutOrderDO.getWarehouseId());
stockOutOrderDO.setWarehouseCode(warehouseFeignPO.getWarehouseCode());
stockOutOrderDO.setWarehouseName(warehouseFeignPO.getWarehouseName());
}
@@ -18,6 +18,10 @@ import com.mhd.oms.domain.businessDeliveryDetailsLink.repository.facade.IBusines
import com.mhd.oms.domain.businessDeliveryDetailsLink.repository.mapper.BusinessDeliveryDetailsLinkMapper;
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
import com.mhd.oms.domain.businessDocumentAddressMulti.entity.BusinessDocumentAddressMulti;
import com.mhd.oms.domain.businessDocumentAddressMulti.repository.mapper.BusinessDocumentAddressMultiMapper;
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
import com.mhd.oms.domain.executeOrder.repository.mapper.ExecuteOrderMapper;
import com.mhd.oms.domain.executionInMaterialDetail.entity.ExecutionInMaterialDetail;
@@ -48,6 +52,8 @@ import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationS
import com.mhd.oms.domain.reservationStockInOrder.repository.po.MaterialBaseInfoPO;
import com.mhd.oms.domain.reservationStockInOrder.repository.todo.ReservationStockInOrderDO;
import com.mhd.oms.domain.reservationStockOutOrder.entity.ReservationStockOutOrder;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.entity.ReservationInventoryAdjustmentRecord;
import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.repository.mapper.ReservationInventoryAdjustmentRecordMapper;
import com.mhd.oms.domain.reservationStockOutOrder.repository.facade.IReservationStockOutOrderService;
import com.mhd.oms.domain.reservationStockOutOrder.repository.mapper.ReservationStockOutOrderMapper;
import com.mhd.oms.domain.reservationStockOutOrder.repository.po.ReservationStockOutOrderPO;
@@ -55,6 +61,7 @@ import com.mhd.oms.domain.reservationStockOutOrder.repository.todo.ReservationSt
import com.mhd.oms.domain.reserveStockOutOrder.repository.mapper.ReserveStockOutOrderMapper;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.WmsServiceFeign;
import com.mhd.system.api.WlhyServiceFeign;
import com.mhd.system.api.domain.*;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
@@ -118,6 +125,16 @@ public class ReservationStockOutOrderDomainService {
private ReserveStockOutOrderMapper reserveStockOutOrderMapper;
@Autowired
private MaterialBaseInfoResolveService materialBaseInfoResolveService;
@Resource
private ReservationInventoryAdjustmentRecordMapper inventoryAdjustmentRecordMapper;
@Resource
private WlhyServiceFeign wlhyServiceFeign;
@Autowired
private BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper;
@Autowired
private BusinessDocumentAddressMultiMapper businessDocumentAddressMultiMapper;
@Autowired
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
/**
* 分页查询出库单列表
@@ -215,6 +232,10 @@ public class ReservationStockOutOrderDomainService {
if (stockOutOrderDO.getCheckTaskDistribution() == null) {
stockOutOrderDO.setCheckTaskDistribution(2);
}
// 订单来源为空时兜底为手动创建导入/预约下发等路径已显式设置不受影响下发执行单时随业务单继承
if (stockOutOrderDO.getReservationOrderSource() == null || stockOutOrderDO.getReservationOrderSource().isEmpty()) {
stockOutOrderDO.setReservationOrderSource("手动创建");
}
stockOutOrderService.insert(stockOutOrderDO);
List<ReservationDeliveryDetailsLink> reservationDeliveryDetailsLinkList = stockOutOrderDO.getReservationDeliveryDetailsLinkList();
if (reservationDeliveryDetailsLinkList != null && !reservationDeliveryDetailsLinkList.isEmpty()){
@@ -409,7 +430,8 @@ public class ReservationStockOutOrderDomainService {
String userRealName = loginUser.getUserPo() != null && loginUser.getUserPo().getUserName() != null
? loginUser.getUserPo().getUserName()
: (loginUser.getRealname() != null ? loginUser.getRealname() : loginUser.getUsername());
boolean updateResult = stockOutOrderService.update(null, new UpdateWrapper<ReservationStockOutOrder>().lambda()
boolean updateResult;
LambdaUpdateWrapper<ReservationStockOutOrder> auditUpdateWrapper = new UpdateWrapper<ReservationStockOutOrder>().lambda()
.set(ReservationStockOutOrder::getReservationAuditId, loginUser.getUserid())
.set(ReservationStockOutOrder::getReservationAuditName, userRealName)
.set(ReservationStockOutOrder::getReservationAuditTime, new Date())
@@ -417,7 +439,12 @@ public class ReservationStockOutOrderDomainService {
.set(ReservationStockOutOrder::getUpdateByName, userRealName)
.set(ReservationStockOutOrder::getUpdateTime, new Date())
.set(ReservationStockOutOrder::getIssueStatus, issueStatus)
.in(ReservationStockOutOrder::getOutOrderId, stockOutOrderDO.getOutOrderIds()));
.in(ReservationStockOutOrder::getOutOrderId, stockOutOrderDO.getOutOrderIds());
// 重新审核通过时复位反审标记: 单据离开已反审页签回到正常流转
if (issueStatus == 2) {
auditUpdateWrapper.set(ReservationStockOutOrder::getReverseStatus, 0);
}
updateResult = stockOutOrderService.update(null, auditUpdateWrapper);
//审核通过时同步线路/车次到关联的运输业务单
if (issueStatus == 2) {
@@ -481,6 +508,125 @@ public class ReservationStockOutOrderDomainService {
}
}
/**
* 重新下发前自愈清理: 历史版本反审/取消下发软删的执行明细(del_flag=2)仍占用unique_id
* (EXECUTION_OUT_MATERIAL_DETAIL 唯一约束不含del_flag), 重新下发从预留明细复制同一unique_id会撞键;
* 归档行的unique_id无功能用途(仅活动明细展示反查批号用到), 统一置空释放键位, 幂等可重复执行
*/
private void releaseArchivedDetailUniqueId(String businessOutOrderNumber) {
List<String> executionOrderNumbers = executionStockOutOrderService.list(new QueryWrapper<ExecutionStockOutOrder>().lambda()
.eq(ExecutionStockOutOrder::getBusinessOutOrderNumber, businessOutOrderNumber))
.stream()
.map(ExecutionStockOutOrder::getOutOrderNumber)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (executionOrderNumbers.isEmpty()) {
return;
}
executionOutMaterialDetailService.update(null, new UpdateWrapper<ExecutionOutMaterialDetail>().lambda()
.set(ExecutionOutMaterialDetail::getUniqueId, null)
.eq(ExecutionOutMaterialDetail::getDelFlag, 2)
.in(ExecutionOutMaterialDetail::getOutOrderNumber, executionOrderNumbers));
}
/**
* 反审联动软删运输链路(编辑"是否运输"= 且审核通过后生成的链), 真实层级:
* 运输业务单-主单(splicingOrderType=4, business_document_order)
* -> 审核运输业务单按配送明细生成子单(splicingOrderType=3, mainOrderId=主单id, 每明细一单)
* -> 下发每个子单各生成一个运输执行单(execute_order.businessDocumentId=子单id, goodsNumber=子单货源号, 主单下无直接执行单)
* -> 每个执行单各推一单TMS(tms_order.execute_order_number=执行单货源号) -> TMS运单/运输作业单(wlhy外部服务)
* 定位运输业务单: 出库单.businessNumber(创建运输业务单时回填的货源单号) inOrderNumber=出库单号兜底
* (businessNumber缺失/已清空场景); 均不滤del_flag此前被旧版反审漏删或手工删过的主单,
* 其子单/执行单/TMS链可能仍存活, 同样要清理(幂等)配送明细链的invoiceNumber存的是送货单号而非出库单号, 不能作为定位条件
* 执行单逐个调 TMS deleteChainByExecuteOrderNumber 软删TMS侧整链(未下发过则TMS无数据, 幂等空操作), 失败抛异常整批回滚;
* 本地软删执行单/主单及子单及其货品/地址明细/配送明细链; 无关联运输单时直接跳过
*/
private void reverseTransportChain(ReservationStockOutOrder byId) {
String outOrderNumber = byId.getOutOrderNumber();
Set<Long> transportOrderIds = new HashSet<>();
if (StringUtils.isNotBlank(byId.getBusinessNumber())) {
businessDocumentOrderMapper.selectList(new LambdaQueryWrapper<BusinessDocumentOrder>()
.eq(BusinessDocumentOrder::getGoodsNumber, byId.getBusinessNumber()))
.forEach(order -> transportOrderIds.add(order.getId()));
}
businessDocumentOrderMapper.selectList(new LambdaQueryWrapper<BusinessDocumentOrder>()
.eq(BusinessDocumentOrder::getInOrderNumber, outOrderNumber))
.forEach(order -> transportOrderIds.add(order.getId()));
if (transportOrderIds.isEmpty()) {
return;
}
for (Long transportOrderId : transportOrderIds) {
BusinessDocumentOrder transportOrder = businessDocumentOrderMapper.selectById(transportOrderId);
if (transportOrder == null) {
continue;
}
// 0. 拆单主单自身无执行单: 收集主单+全部子单id, 执行单/货品/地址明细按全量id清理
List<BusinessDocumentOrder> subOrders = businessDocumentOrderMapper.selectList(new LambdaQueryWrapper<BusinessDocumentOrder>()
.eq(BusinessDocumentOrder::getMainOrderId, String.valueOf(transportOrderId))
.eq(BusinessDocumentOrder::getDelFlag, 1));
Set<Long> chainDocIds = new HashSet<>();
chainDocIds.add(transportOrderId);
subOrders.forEach(subOrder -> chainDocIds.add(subOrder.getId()));
// 1. 执行单: 不滤del_flag历史周期已归档执行单的TMS链也幂等补清("执行单已删TMS残留"),
// 先逐个软删TMS侧整链(货源单->运单->作业单), 再软删本地执行单(已归档的跳过更新)
List<ExecuteOrder> executeOrders = executeOrderMapper.selectList(new LambdaQueryWrapper<ExecuteOrder>()
.in(ExecuteOrder::getBusinessDocumentId, chainDocIds));
for (ExecuteOrder executeOrder : executeOrders) {
if (StringUtils.isNotBlank(executeOrder.getGoodsNumber())) {
AjaxResult tmsResult = wlhyServiceFeign.deleteChainByExecuteOrderNumber(executeOrder.getGoodsNumber());
if (tmsResult == null || !"200".equals(String.valueOf(tmsResult.get("code")))) {
throw new ServiceException("出库单[" + outOrderNumber + "]反审失败: 运输执行单货源单号["
+ executeOrder.getGoodsNumber() + "]TMS链路软删失败: "
+ (tmsResult == null ? "TMS服务不可用" : tmsResult.get("msg")));
}
}
if (!Integer.valueOf(2).equals(executeOrder.getDelFlag())) {
executeOrder.setDelFlag(2);
executeOrderMapper.updateById(executeOrder);
}
}
// 2. 软删运输业务单(主单+子单)及其货品/地址明细(主单已软删的只补清理子单/明细, 不重复更新主单)
if (!Integer.valueOf(2).equals(transportOrder.getDelFlag())) {
transportOrder.setDelFlag(2);
businessDocumentOrderMapper.updateById(transportOrder);
}
for (BusinessDocumentOrder subOrder : subOrders) {
subOrder.setDelFlag(2);
businessDocumentOrderMapper.updateById(subOrder);
}
List<String> chainDocIdStrings = chainDocIds.stream().map(String::valueOf).collect(Collectors.toList());
businessDocumentCargoMultiMapper.update(null, new LambdaUpdateWrapper<BusinessDocumentCargoMulti>()
.set(BusinessDocumentCargoMulti::getDelFlag, 2)
.in(BusinessDocumentCargoMulti::getOrderId, chainDocIdStrings)
.eq(BusinessDocumentCargoMulti::getDelFlag, 1));
businessDocumentAddressMultiMapper.update(null, new LambdaUpdateWrapper<BusinessDocumentAddressMulti>()
.set(BusinessDocumentAddressMulti::getDelFlag, 2)
.in(BusinessDocumentAddressMulti::getOrderId, chainDocIdStrings)
.eq(BusinessDocumentAddressMulti::getDelFlag, 1));
}
// 3. 配送明细链软删: 链的orderId固定指向运输业务单-主单, 按本次命中的主单id清理(含历史周期残留链)
businessDeliveryDetailsLinkService.update(null, new LambdaUpdateWrapper<BusinessDeliveryDetailsLink>()
.set(BusinessDeliveryDetailsLink::getDelFlag, 2)
.in(BusinessDeliveryDetailsLink::getOrderId, transportOrderIds)
.eq(BusinessDeliveryDetailsLink::getDelFlag, 1));
}
/**
* 获取仓库信息(Feign优先, system服务失败/降级时本地跨库兜底), 统一委托共享组件
*/
private WarehouseFeignPO getWarehouseInfoWithFallback(Long warehouseId) {
return warehouseInfoApplicationService.getWarehouseInfo(warehouseId);
}
/**
* 获取仓库单号生成规则(下发生成执行单号用): 优先 Feign system 服务;
* Feign 异常/降级/返回非200时回退本地跨库直查 NGWL_TEST_SYSTEM.WAREHOUSE(同库同表, getWarehouseCode 等查询同数据源),
* 避免 system 服务抖动阻断下发; 两侧都取不到才报错并带出 Feign 真实返回原因
*/
private WarehouseFeignPO getWarehouseOrderNoRule(Long warehouseId) {
return getWarehouseInfoWithFallback(warehouseId);
}
/**
* @description 审核出库单
* @author ZhouGY
@@ -521,8 +667,14 @@ public class ReservationStockOutOrderDomainService {
if (activeExecutionCount > 0) {
throw new ServiceException("出库单[" + inOrderNumber + "]已下发,请勿重复下发;如需重新下发请先取消下发");
}
// 自愈: 历史版本反审/取消下发的归档明细可能仍占用unique_id, 先置空释放键位再重新下发
releaseArchivedDetailUniqueId(inOrderNumber);
List<String> executionInOrderNumbers = new ArrayList<>();
List<ReservationOutMaterialDetail> materialDetailList = outMaterialDetailService.list(new QueryWrapper<ReservationOutMaterialDetail>().lambda().eq(ReservationOutMaterialDetail::getOutOrderNumber, inOrderNumber));
// 下发明细必须过滤软删行(del_flag=1)编辑对账软删的旧行仍留表内
// 不滤会参与按仓库分组/数量汇总多生成执行单且数量叠加(入库侧同查询已过滤)
List<ReservationOutMaterialDetail> materialDetailList = outMaterialDetailService.list(new QueryWrapper<ReservationOutMaterialDetail>().lambda()
.eq(ReservationOutMaterialDetail::getOutOrderNumber, inOrderNumber)
.eq(ReservationOutMaterialDetail::getDelFlag, 1));
// 按照 warehouseId 分组
Map<Long, List<ReservationOutMaterialDetail>> materialDetailGroupByWarehouse = materialDetailList.stream()
@@ -540,7 +692,6 @@ public class ReservationStockOutOrderDomainService {
reservationStockInOrder.setOrderTypeCode("pu_tong_chu_ku");
reservationStockInOrder.setOrderTypeName("普通出库");
reservationStockInOrder.setBusinessType("pu_tong_chu_ku");
reservationStockInOrder.setReservationOrderSource("客户预约");
reservationStockInOrder.setWarehouseId(warehouseId);
reservationStockInOrder.setWarehouseCode(warehouseCode);
reservationStockInOrder.setWarehouseName(warehouseName);
@@ -556,14 +707,8 @@ public class ReservationStockOutOrderDomainService {
reservationStockInOrder.setBusinessOutOrderNumber(inOrderNumber);
// reservationStockInOrder.setOutOrderNumber(generateExecutionOrderNumber(warehouseCode));
//设置单号
Long warehouseId1 = reservationStockInOrder.getWarehouseId();
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId1);
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("获取仓库信息失败");
}
//仓库信息
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
//设置单号(仓库单号规则: Feign优先, system服务失败/降级时本地跨库兜底)
WarehouseFeignPO warehouseFeignPO = getWarehouseOrderNoRule(reservationStockInOrder.getWarehouseId());
String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule();
String prefix = warehouseFeignPO.getOutOrderNoPrefix();
if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) {
@@ -652,6 +797,8 @@ public class ReservationStockOutOrderDomainService {
materialDetails.forEach(executionOutMaterialDetail -> {
executionOutMaterialDetailService.update(null, new UpdateWrapper<ExecutionOutMaterialDetail>().lambda()
.set(ExecutionOutMaterialDetail::getDelFlag, 2)
// 归档行置空uniqueId: 明细表唯一约束不含del_flag, 保留原值会与重新下发时从预留明细复制的同一uniqueId撞键
.set(ExecutionOutMaterialDetail::getUniqueId, null)
.eq(ExecutionOutMaterialDetail::getMaterialDetailId, executionOutMaterialDetail.getMaterialDetailId()));
});
executionStockOutOrderService.update(null, new UpdateWrapper<ExecutionStockOutOrder>().lambda()
@@ -662,6 +809,129 @@ public class ReservationStockOutOrderDomainService {
return update;
}
/**
* @description 反审出库业务单(按前端展示字段 issueStatus 判断可反审范围: 2-已审核(未出库) / 4-已出库 均可反审;
* 0-已创建无需反审3-已驳回可直接编辑; status 字段在出库完成后不一定同步为9, 故不作为判断依据,
* 仅兜底排除 10-已取消/11-已关闭)
* 反审将单据回退到已创建(status=1)且审核状态置为已驳回(issueStatus=3, 与入库侧反审同口径, 可编辑重新审核重新下发)
* 并打上反审标记:
* WMS 侧按出库单实际状态分支还原库存(已出库: 实物库存还原+推OMS; 未出库: 仅还原分配/冻结占用)
* 清理执行单据(出库单/明细/拣货/复核/交接/配送, 软删+reverseFlag=1 划归已反审tab)
* 每个执行出库单生成1条出库异常记录反审记录(out_order_abnormal, abnormalType=3);
* OMS 侧软删执行出库单及明细软删预约库存调整记录
* 反审后单据进入已反审页签(status=1 reverse_status=1), 可继续编辑/审核/撤销;
* 重新审核通过时 reverse_status 自动复位 0( auditState)
* @date 2026/9/8
*/
@Transactional(rollbackFor = Exception.class)
public Boolean reverseAudit(ReservationStockOutOrderDO stockOutOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 获取用户姓名优先从UserPo获取如果为空则使用realname最后使用username作为兜底
String userRealName = loginUser.getUserPo() != null && loginUser.getUserPo().getUserName() != null
? loginUser.getUserPo().getUserName()
: (loginUser.getRealname() != null ? loginUser.getRealname() : loginUser.getUsername());
List<Long> outOrderIds = stockOutOrderDO.getOutOrderIds();
if (outOrderIds == null || outOrderIds.isEmpty()) {
throw new ServiceException("请选择需要反审的出库单");
}
String reverseRemark = stockOutOrderDO.getReverseRemark();
for (Long outOrderId : outOrderIds) {
ReservationStockOutOrder byId = stockOutOrderService.getById(outOrderId);
if (byId == null) {
throw new ServiceException("出库单不存在, outOrderId=" + outOrderId);
}
Integer status = byId.getStatus();
if (status != null && (status == 10 || status == 11)) {
throw new ServiceException("出库单[" + byId.getOutOrderNumber() + "]已取消/已关闭, 不能反审");
}
// 反审条件按前端展示字段 issueStatus 判断: 2-已审核(未出库) / 4-已出库 均可反审
Integer issueStatus = byId.getIssueStatus();
if (!Integer.valueOf(2).equals(issueStatus) && !Integer.valueOf(4).equals(issueStatus)) {
throw new ServiceException("出库单[" + byId.getOutOrderNumber() + "]当前状态(issueStatus=" + issueStatus
+ ")不支持反审, 仅已审核/已出库状态可反审");
}
// 逐个执行出库单调 WMS 反审: 还原实物库存+推送OMS库存清理WMS单据生成反审异常记录;
// 任一失败抛异常整体回滚, 避免单边反审
List<ExecutionStockOutOrder> executionOrders = executionStockOutOrderService.list(new QueryWrapper<ExecutionStockOutOrder>().lambda()
.eq(ExecutionStockOutOrder::getBusinessOutOrderNumber, byId.getOutOrderNumber())
.eq(ExecutionStockOutOrder::getDelFlag, 1));
for (ExecutionStockOutOrder executionStockOutOrder : executionOrders) {
String executionOutOrderNumber = executionStockOutOrder.getOutOrderNumber();
StockOutOrder wmsOutOrder = new StockOutOrder();
wmsOutOrder.setOutOrderNumber(executionOutOrderNumber);
// 反审原因经 remark 透传 WMS, 记入反审异常记录备注
wmsOutOrder.setRemark("业务单号:" + byId.getOutOrderNumber()
+ (reverseRemark != null && !reverseRemark.isEmpty() ? ",反审原因:" + reverseRemark : ""));
AjaxResult wmsResult = wmsServiceFeign.omsReverseExecutionOrder(wmsOutOrder);
if (wmsResult == null || !"200".equals(String.valueOf(wmsResult.get("code")))) {
throw new ServiceException("执行出库单[" + executionOutOrderNumber + "]WMS反审失败:"
+ (wmsResult == null ? "WMS服务不可用" : wmsResult.get("msg")));
}
// 软删执行出库单明细 + 执行出库单(与取消下发 cancelIssueOrder 一致)
List<ExecutionOutMaterialDetail> materialDetails = executionOutMaterialDetailService.list(new QueryWrapper<ExecutionOutMaterialDetail>().lambda()
.eq(ExecutionOutMaterialDetail::getOutOrderNumber, executionOutOrderNumber)
.eq(ExecutionOutMaterialDetail::getDelFlag, 1));
materialDetails.forEach(executionOutMaterialDetail -> {
executionOutMaterialDetailService.update(null, new UpdateWrapper<ExecutionOutMaterialDetail>().lambda()
.set(ExecutionOutMaterialDetail::getDelFlag, 2)
.set(ExecutionOutMaterialDetail::getReverseFlag, 1)
// 归档行置空uniqueId: 明细表唯一约束不含del_flag, 保留原值会与重新下发时从预留明细复制的同一uniqueId撞键
.set(ExecutionOutMaterialDetail::getUniqueId, null)
.eq(ExecutionOutMaterialDetail::getMaterialDetailId, executionOutMaterialDetail.getMaterialDetailId()));
});
executionStockOutOrderService.update(null, new UpdateWrapper<ExecutionStockOutOrder>().lambda()
.set(ExecutionStockOutOrder::getDelFlag, 2)
.set(ExecutionStockOutOrder::getReverseFlag, 1)
.eq(ExecutionStockOutOrder::getOutOrderNumber, executionOutOrderNumber));
// 软删预约库存调整记录(下发分配时生成): 仅软删留痕, 库存数量由 WMS omsEdit 推送还原
inventoryAdjustmentRecordMapper.update(null, new UpdateWrapper<ReservationInventoryAdjustmentRecord>().lambda()
.set(ReservationInventoryAdjustmentRecord::getDelFlag, 2)
.eq(ReservationInventoryAdjustmentRecord::getExecutionOrderNumber, executionOutOrderNumber)
.eq(ReservationInventoryAdjustmentRecord::getDelFlag, 1));
}
// 反审联动: 软删关联运输链路(运输业务单/运输执行单/TMS货源单-运单-作业单), 无关联运输单时跳过
reverseTransportChain(byId);
}
// 主单回退到已创建并打反审标记; 更新条件带 issueStatus in (2,4) + 排除已取消/已关闭 兜底防并发重复反审
// issueStatus 回退到 3-已驳回(前端展示映射: 0-已创建 2-已审核 3-已驳回 4-已出库; 与入库侧反审同口径,
// 已驳回态可编辑重新审核重新下发, 重新审核通过时 reverse_status 自动复位 0 离开已反审tab);
// 清空执行出库单号执行单已随反审软删, 前端"是否执行"列由该字段有无值推导, 不清空会仍显示已执行
return stockOutOrderService.update(null, new UpdateWrapper<ReservationStockOutOrder>().lambda()
.set(ReservationStockOutOrder::getStatus, 1)
.set(ReservationStockOutOrder::getIssueStatus, 3)
.set(ReservationStockOutOrder::getExecutionOutOrderNumber, null)
// 运输业务单已随反审软删, 货源单号一并清空, 重新审核后重建运输链路时自动回填
.set(ReservationStockOutOrder::getBusinessNumber, null)
.set(ReservationStockOutOrder::getIssueId, null)
.set(ReservationStockOutOrder::getIssueName, null)
.set(ReservationStockOutOrder::getIssueTime, null)
.set(ReservationStockOutOrder::getReservationAuditId, null)
.set(ReservationStockOutOrder::getReservationAuditName, null)
.set(ReservationStockOutOrder::getReservationAuditTime, null)
.set(ReservationStockOutOrder::getAllocationQuantity, BigDecimal.ZERO)
.set(ReservationStockOutOrder::getAlreadyAllocationQuantity, BigDecimal.ZERO)
.set(ReservationStockOutOrder::getPickingQuantity, BigDecimal.ZERO)
.set(ReservationStockOutOrder::getCheckQuantity, BigDecimal.ZERO)
.set(ReservationStockOutOrder::getCheckStatus, 1)
.set(ReservationStockOutOrder::getCheckTaskDistribution, 2)
.set(ReservationStockOutOrder::getCheckTaskDistributionTime, null)
.set(ReservationStockOutOrder::getCompleteTime, null)
.set(ReservationStockOutOrder::getOutboundTime, null)
.set(ReservationStockOutOrder::getReverseStatus, 1)
.set(ReservationStockOutOrder::getReverseBy, loginUser.getUserid())
.set(ReservationStockOutOrder::getReverseByName, userRealName)
.set(ReservationStockOutOrder::getReverseTime, new Date())
.set(ReservationStockOutOrder::getReverseRemark, reverseRemark)
.set(ReservationStockOutOrder::getUpdateBy, loginUser.getUserid())
.set(ReservationStockOutOrder::getUpdateByName, userRealName)
.set(ReservationStockOutOrder::getUpdateTime, new Date())
.in(ReservationStockOutOrder::getOutOrderId, outOrderIds)
.in(ReservationStockOutOrder::getIssueStatus, 2, 4)
.notIn(ReservationStockOutOrder::getStatus, 10, 11));
}
@Transactional(rollbackFor = Exception.class)
public Boolean executeAndIssue(ReservationStockOutOrderDO stockOutOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -691,7 +961,13 @@ public class ReservationStockOutOrderDomainService {
String warehouseCode1 = byId.getWarehouseCode();
String warehouseName1 = byId.getWarehouseName();
String inOrderNumber = byId.getOutOrderNumber();
List<ReservationOutMaterialDetail> materialDetailList = outMaterialDetailService.list(new QueryWrapper<ReservationOutMaterialDetail>().lambda().eq(ReservationOutMaterialDetail::getOutOrderNumber, inOrderNumber));
// 自愈: 历史版本反审/取消下发的归档明细可能仍占用unique_id, 先置空释放键位再重新下发
releaseArchivedDetailUniqueId(inOrderNumber);
// 下发明细必须过滤软删行(del_flag=1)编辑对账软删的旧行仍留表内
// 不滤会参与按仓库分组/数量汇总多生成执行单且数量叠加(入库侧同查询已过滤)
List<ReservationOutMaterialDetail> materialDetailList = outMaterialDetailService.list(new QueryWrapper<ReservationOutMaterialDetail>().lambda()
.eq(ReservationOutMaterialDetail::getOutOrderNumber, inOrderNumber)
.eq(ReservationOutMaterialDetail::getDelFlag, 1));
// 按照 warehouseId 分组
Map<Long, List<ReservationOutMaterialDetail>> materialDetailGroupByWarehouse = materialDetailList.stream()
@@ -755,7 +1031,6 @@ public class ReservationStockOutOrderDomainService {
reservationStockInOrder.setOrderTypeCode("pu_tong_chu_ku");
reservationStockInOrder.setOrderTypeName("普通出库");
reservationStockInOrder.setBusinessType("pu_tong_chu_ku");
reservationStockInOrder.setReservationOrderSource("客户预约");
reservationStockInOrder.setWarehouseId(warehouseId);
reservationStockInOrder.setOrganizationId(orgId);
reservationStockInOrder.setOrganizationName(orgName);
@@ -765,14 +1040,8 @@ public class ReservationStockOutOrderDomainService {
reservationStockInOrder.setBusinessOutOrderNumber(inOrderNumber);
//设置单号
// Long warehouseId1 = reservationStockInOrder.getWarehouseId();
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId);
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("获取仓库信息失败");
}
//仓库信息
WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
//设置单号(仓库单号规则: Feign优先, system服务失败/降级时本地跨库兜底)
WarehouseFeignPO warehouseFeignPO = getWarehouseOrderNoRule(warehouseId);
String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule();
String prefix = warehouseFeignPO.getOutOrderNoPrefix();
if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) {
@@ -68,6 +68,8 @@ import java.util.concurrent.ThreadLocalRandom;
public class ReserveStockOutOrderApplicationService {
@Autowired
private ReserveStockOutOrderDomainService stockOutOrderDomainService;
@Autowired
private com.mhd.oms.application.service.WarehouseInfoApplicationService warehouseInfoApplicationService;
// @Autowired
// private ReserveOutMaterialDetailDomainService outMaterialDetailDomainService;
// @Autowired
@@ -895,11 +897,8 @@ public class ReserveStockOutOrderApplicationService {
if (stockOutOrderDO.getWarehouseId() == null) {
throw new ServiceException("仓库ID不能为空");
}
AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(stockOutOrderDO.getWarehouseId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("获取仓库信息失败");
}
WarehouseFeignPO warehouseFeignPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class);
// Feign失败走本地跨库兜底, 避免保存被"获取仓库信息失败"阻断
WarehouseFeignPO warehouseFeignPO = warehouseInfoApplicationService.getWarehouseInfo(stockOutOrderDO.getWarehouseId());
stockOutOrderDO.setWarehouseCode(warehouseFeignPO.getWarehouseCode());
stockOutOrderDO.setWarehouseName(warehouseFeignPO.getWarehouseName());
}
@@ -22,8 +22,7 @@ import java.util.Map;
/**
* 三方服务 Feign
*/
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定未配置时按服务名走服务发现
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.31:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.33.0.129:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
public interface ThirdPartyServiceFeign {
//查询当前组织所有三方接口信息
@@ -1,24 +0,0 @@
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;
}
@@ -1,37 +0,0 @@
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;
}
@@ -1,36 +0,0 @@
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;
}
@@ -1,59 +0,0 @@
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;
}
@@ -159,6 +159,17 @@ public class ReservationStockOutOrderApi extends BaseController {
return AjaxResult.success(stockOutOrderApplicationService.cancelIssueOrder(stockOutOrderDO));
}
/**
* 反审出库单: 已出库/已复核(issueStatus=2已审核)的单据回退到已创建并打反审标记,
* WMS还原实物库存并生成出库异常记录反审记录, 单据划归已反审页签
*/
@ApiOperation("反审出库单")
@PostMapping(value = "/reverseAudit")
public AjaxResult reverseAudit(@RequestBody ReservationStockOutOrderDTO stockOutOrderDTO) {
ReservationStockOutOrderDO stockOutOrderDO = stockOutOrderAssembler.toDO(stockOutOrderDTO);
return AjaxResult.success(stockOutOrderApplicationService.reverseAudit(stockOutOrderDO));
}
@ApiOperation("下发出库单")
@PostMapping(value = "/executeAndIssue")
public AjaxResult executeAndIssue(@RequestBody ReservationStockOutOrderDTO stockOutOrderDTO) {
@@ -10,12 +10,7 @@ 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;
@@ -38,9 +33,6 @@ public class BusinessDocumentOrderApi extends BaseController{
@Resource
private BusinessDocumentOrderAssembler businessDocumentOrderAssembler;
@Resource
private BusinessDocumentOrderAdjustService businessDocumentOrderAdjustService;
/**
* 分页查询业务单列表
*/
@@ -169,64 +161,7 @@ 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());
}
}
}
@@ -3,6 +3,7 @@ package com.mhd.oms.interfaces.facade.executionInMaterialDetail;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO;
import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO;
import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO;
@@ -16,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
/**
@@ -96,4 +99,24 @@ public class ExecutionInMaterialDetailApi extends BaseController {
return getDataTable(list);
}
/**
* 导出入库明细查询Excel关联入库执行单全量不分页
* SQL固定只统计已入库(5)单据可按单据类型(如退货入库tui_huo_ru_ku)与实际入仓日期区间过滤
*/
@ApiOperation("导出入库明细查询Excel")
@GetMapping("/exportWithOrder")
public void exportWithOrder(HttpServletResponse response, ExecutionInMaterialDetailQueryDTO queryDTO) throws Exception
{
//转换实体不分页导出全量
QueryOrderOverStockDO queryDO = inMaterialDetailAssembler.toQueryDO(queryDTO);
List<ExecutionInMaterialDetailWithOrderPO> list = inMaterialDetailApplicationService.exportInOrderDetailList(queryDO);
String fileName = URLEncoder.encode("入库明细查询", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<ExecutionInMaterialDetailWithOrderPO> util = new ExcelUtil<>(ExecutionInMaterialDetailWithOrderPO.class);
util.exportExcel(response, list, "入库明细查询");
}
}
@@ -2,6 +2,7 @@ package com.mhd.oms.interfaces.facade.executionOutMaterialDetail;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO;
import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailQueryDTO;
import com.mhd.oms.domain.executionOutMaterialDetail.service.ExecutionOutMaterialDetailApplicationService;
@@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
/**
@@ -41,4 +44,23 @@ public class ExecutionOutMaterialDetailApi extends BaseController {
List<ExecutionOutMaterialDetailWithOrderPO> list = outMaterialDetailApplicationService.queryOutOrderDetailList(queryDO);
return getDataTable(list);
}
/**
* 导出出库明细查询Excel关联出库执行单全量不分页
* SQL固定只统计已出库(9/12/13)单据可按单据类型与实际出仓日期区间过滤
*/
@ApiOperation("导出出库明细查询Excel")
@GetMapping("/exportWithOrder")
public void exportWithOrder(HttpServletResponse response, ExecutionOutMaterialDetailQueryDTO queryDTO) throws Exception {
//转换实体不分页导出全量
QueryOrderOverStockDO queryDO = outMaterialDetailAssembler.toQueryDO(queryDTO);
List<ExecutionOutMaterialDetailWithOrderPO> list = outMaterialDetailApplicationService.queryOutOrderDetailList(queryDO);
String fileName = URLEncoder.encode("出库明细查询", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<ExecutionOutMaterialDetailWithOrderPO> util = new ExcelUtil<>(ExecutionOutMaterialDetailWithOrderPO.class);
util.exportExcel(response, list, "出库明细查询");
}
}
@@ -93,6 +93,16 @@ public class ExecutionStockInOrderApi extends BaseController {
return AjaxResult.success(stockInOrderApplicationService.getInfo(inOrderId));
}
/**
* 查询入库执行单已反审tab 归档详情已软删+已反审标记的数据含软删明细
*/
@ApiOperation("查询入库执行单已反审归档详情")
@GetMapping(value = "/getReverseAuditInfo/{inOrderId}")
public AjaxResult getReverseAuditInfo(@PathVariable("inOrderId") Long inOrderId)
{
return AjaxResult.success(stockInOrderApplicationService.getReverseAuditInfo(inOrderId));
}
/**
* 导入入库单
*/
@@ -122,6 +122,19 @@ public class ReservationStockInOrderApi extends BaseController {
return AjaxResult.success(stockInOrderApplicationService.auditState(stockInOrderDO));
}
/**
* 反审入库业务单已入库/已出库的单子客户通知需要回退的场景单子回退到最原始状态
* 业务单状态改为"已驳回"(issueStatus=3与审核不通过同语义可编辑重新审核重新下发)
* 并打已反审标记落入已反审tab入库执行单+明细软删并打已反审标记
* W入库单有出库记录时WMS侧拦截不允许反审已推送关务(pushStatus=3)直接拦截
*/
@ApiOperation("反审入库业务单")
@PostMapping(value = "/reverseAudit")
public AjaxResult reverseAudit(@RequestBody ReservationStockInOrderDTO stockInOrderDTO) {
ReservationStockInOrderDO stockInOrderDO = stockInOrderAssembler.toDO(stockInOrderDTO);
return AjaxResult.success(stockInOrderApplicationService.reverseAudit(stockInOrderDO));
}
/**
* 下发入库单
*/
+4 -4
View File
@@ -18,15 +18,15 @@ spring:
discovery:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
config:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
#线上正式环境
@@ -1278,8 +1278,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select PUSH_VERIFY from NGWL_TEST_PRODUCT.SYS_ORGANIZATION where ORGANIZATION_ID = #{organizationId}
</select>
<select id="countByGoodsNumberPrefix" resultType="java.lang.Integer">
SELECT COUNT(1)
<select id="selectGoodsNumbersByPrefix" resultType="java.lang.String">
SELECT goods_number
FROM business_document_order
WHERE goods_number LIKE concat(#{prefix}, '%')
AND LENGTH(goods_number) &lt;= 12
@@ -42,6 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectExecuteOrderPo1">
<where>
<!-- 默认只查正常单(del_flag=1); 反审/删除的归档行需显式传delFlag=2(已反审tab) -->
<choose>
<when test="delFlag != null">and eo.DEL_FLAG = #{delFlag}</when>
<otherwise>and eo.DEL_FLAG = 1</otherwise>
</choose>
<if test="createStartTime != null">
and eo.CREATE_TIME &gt;= #{createStartTime}
</if>
@@ -365,6 +365,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO" id="InMaterialDetailWithOrderResult" extends="MaterialDetailResult">
<result property="inOrderStatus" column="in_order_status" />
<result property="inOrderAuditStatus" column="in_order_audit_status" />
<result property="issueStatus" column="issue_status" />
<result property="materialClassifyName" column="material_classify_name" />
<result property="orderTypeCode" column="order_type_code" />
<result property="orderTypeName" column="order_type_name" />
<result property="orderShipperId" column="order_shipper_id" />
<result property="orderShipperCode" column="order_shipper_code" />
<result property="orderShipperName" column="order_shipper_name" />
@@ -403,12 +407,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.single_volume, a.single_gross_weight, a.lot_no,
a.drink_date, a.fire_insure_fee, a.unit_price,
a.line_num_gw, a.spec_gw, a.unit_gw, a.qty_gw, a.erp_curr_gw, a.erp_price_gw, a.amount_gw,
c.insure_amount, c.goods_type,
c.insure_amount, c.goods_type, c.material_classify_name,
b.shipper_id as order_shipper_id,
b.shipper_code as order_shipper_code,
b.shipper_name as order_shipper_name,
b.order_type_code,
b.order_type_name,
b.status as in_order_status,
b.audit_status as in_order_audit_status,
b.issue_status as issue_status,
b.warehouse_date
from execution_in_material_detail a
left join execution_stock_in_order b on a.in_order_number = b.in_order_number
@@ -450,15 +457,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="inOrderTypeCode != null and inOrderTypeCode != ''">
and b.order_type_code = #{inOrderTypeCode}
</if>
<if test="inStatus != null ">
and b.status = #{inStatus}
<if test="orderTypeCode != null and orderTypeCode != ''">
and b.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and b.order_type_name like concat('%', #{orderTypeName}, '%')
</if>
<!-- 入库单展示状态issue_status: 0-已创建 2-已审核 3-已驳回 4-已入库(WMS回写status=5时同步为4)
"已入库"以issue_status=4为准(推送创建的单据直接置4status不一定为5 -->
and b.issue_status = 4
<if test="inOrderExpectStartTime != null">
and b.expect_time &gt;= #{inOrderExpectStartTime}
</if>
<if test="inOrderExpectEndTime != null">
and b.expect_time &lt;= #{inOrderExpectEndTime}
</if>
<!-- 实际入仓日期区间(为空的历史单按建档时间兜底),用于统计当天入库 -->
<if test="warehouseDateStart != null and warehouseDateStart != ''">
and date_format(IFNULL(b.warehouse_date, b.create_time), '%Y-%m-%d') &gt;= #{warehouseDateStart}
</if>
<if test="warehouseDateEnd != null and warehouseDateEnd != ''">
and date_format(IFNULL(b.warehouse_date, b.create_time), '%Y-%m-%d') &lt;= #{warehouseDateEnd}
</if>
and a.del_flag = 1
and b.del_flag = 1
</where>
@@ -454,6 +454,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
id="OutMaterialDetailWithOrderResult" extends="MaterialDetailResult">
<result property="outOrderStatus" column="out_order_status" />
<result property="outOrderAuditStatus" column="out_order_audit_status" />
<result property="issueStatus" column="issue_status" />
<result property="materialClassifyName" column="material_classify_name" />
<result property="orderTypeCode" column="order_type_code" />
<result property="orderTypeName" column="order_type_name" />
<result property="orderShipperId" column="order_shipper_id" />
<result property="orderShipperCode" column="order_shipper_code" />
<result property="orderShipperName" column="order_shipper_name" />
@@ -495,14 +499,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.stock_unit, a.stock_quantity, a.inventory_quantity,
a.line_num_gw, a.spec_gw, a.unit_gw, a.qty_gw,
a.erp_curr_gw, a.erp_price_gw, a.amount_gw, a.in_order_number_gw, a.in_line_num_gw,
c.insure_amount, c.goods_type,
c.insure_amount, c.goods_type, c.material_classify_name,
b.shipper_id as order_shipper_id,
b.shipper_code as order_shipper_code,
b.shipper_name as order_shipper_name,
b.order_type_code,
b.order_type_name,
b.OUTBOUND_DATE as order_outbound_date,
b.OUTBOUND_TIME as order_outbound_time,
b.status as out_order_status,
b.audit_status as out_order_audit_status
b.audit_status as out_order_audit_status,
b.issue_status as issue_status
from execution_out_material_detail a
left join execution_stock_out_order b on a.out_order_number = b.out_order_number
left join NGWL_TEST_WMS.material_base_info c on a.material_base_info_id = c.material_base_info_id
@@ -543,15 +550,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="outOrderTypeCode != null and outOrderTypeCode != ''">
and b.order_type_code = #{outOrderTypeCode}
</if>
<if test="outStatus != null ">
and b.status = #{outStatus}
<if test="orderTypeCode != null and orderTypeCode != ''">
and b.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and b.order_type_name like concat('%', #{orderTypeName}, '%')
</if>
<!-- 出库单展示状态issue_status: 0-已创建 2-已审核 3-已驳回 4-已出库;
执行出库单status不随WMS出库完成流转(回写被注释)"已出库"以issue_status=4为准 -->
and b.issue_status = 4
<if test="outOrderExpectStartTime != null">
and b.expect_time &gt;= #{outOrderExpectStartTime}
</if>
<if test="outOrderExpectEndTime != null">
and b.expect_time &lt;= #{outOrderExpectEndTime}
</if>
<!-- 出库时间区间(统计当天出库):严格按出仓日期OUTBOUND_DATE过滤(页面所见即所筛) -->
<if test="outboundDateStart != null and outboundDateStart != ''">
and date_format(b.OUTBOUND_DATE, '%Y-%m-%d') &gt;= #{outboundDateStart}
</if>
<if test="outboundDateEnd != null and outboundDateEnd != ''">
and date_format(b.OUTBOUND_DATE, '%Y-%m-%d') &lt;= #{outboundDateEnd}
</if>
and a.del_flag = 1
and b.del_flag = 1
</where>
@@ -108,6 +108,11 @@
<result property="discount" column="DISCOUNT" />
<result property="isFreeManpowerFee" column="IS_FREE_MANPOWER_FEE" />
<result property="businessInOrderNumber" column="BUSINESS_IN_ORDER_NUMBER" />
<result property="reverseAuditStatus" column="REVERSE_AUDIT_STATUS" />
<result property="reverseAuditRemark" column="REVERSE_AUDIT_REMARK" />
<result property="reverseAuditBy" column="REVERSE_AUDIT_BY" />
<result property="reverseAuditByName" column="REVERSE_AUDIT_BY_NAME" />
<result property="reverseAuditTime" column="REVERSE_AUDIT_TIME" />
</resultMap>
@@ -145,7 +150,8 @@
a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.reservation_audit_time,a.reservation_audit_name
,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.RESERVATION_ORDER_SOURCE,a.tms_order_number
,a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.STORAGE_TIME,a.in_quantity,
a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME
a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,
a.REVERSE_AUDIT_STATUS,a.REVERSE_AUDIT_REMARK,a.REVERSE_AUDIT_BY,a.REVERSE_AUDIT_BY_NAME,a.REVERSE_AUDIT_TIME
</sql>
<sql id="joinStockInOrderPo">
@@ -288,7 +294,7 @@
and a.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and (a.BUSINESS_TYPE like concat('%', #{orderTypeName}, '%') or a.ORDER_TYPE_CODE like concat('%', #{orderTypeName}, '%'))
and (a.ORDER_TYPE_NAME like concat('%', #{orderTypeName}, '%') or a.BUSINESS_TYPE like concat('%', #{orderTypeName}, '%') or a.ORDER_TYPE_CODE like concat('%', #{orderTypeName}, '%'))
</if>
<if test="supplierId != null ">
and a.supplier_id = #{supplierId}
@@ -501,9 +507,18 @@
</if>
)
</if>
<!-- 反审状态过滤:入库执行单【已反审】tab 传 reverseAuditStatus=1,查询已软删且打反审标记的归档数据 -->
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
<when test="reverseAuditStatus != null">
and a.REVERSE_AUDIT_STATUS = #{reverseAuditStatus}
and a.del_flag = 2
</when>
<otherwise>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</otherwise>
</choose>
</sql>
@@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
<result property="reverseFlag" column="reverse_flag" />
<result property="overStockId" column="over_stock_id" />
<result property="overStockStatus" column="over_stock_status" />
<result property="overStockType" column="over_stock_type" />
@@ -127,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.cancel_time, a.close_order, a.close_remark, a.close_by, a.close_by_name, a.close_time, a.check_status,a.BUSINESS_ORDER_NO,
a.check_task_distribution, a.check_task_distribution_time, a.check_operators_by, a.check_operators_name, a.mobilize_code,
a.remark, a.create_time, a.create_by, a.create_by_name,a.business_number,a.train_no,a.amount,a.business_out_order_number,
a.update_time, a.update_by, a.update_by_name, a.del_flag, a.over_stock_id, a.over_stock_status, a.over_stock_type,a."TO",
a.update_time, a.update_by, a.update_by_name, a.del_flag, a.reverse_flag, a.over_stock_id, a.over_stock_status, a.over_stock_type,a."TO",
a.CONTACT_PERSON,a.VEHICLE_MODEL_PLATE,a.ENTRUST_NO,a.TEL,a.DRIVER_SIGN,a.FAX,a.DECLARE_CUSTOMS,a.MANUFACTURER,
a.CUSTOMS_DECLARER_INFO,a.DELIVERY_ADDR,a.ENTRY_EXIT_CUSTOMS,a.DEPARTURE_ARRIVAL_COUNTRY,a.CARRIER,a.CONTAINER_NO,a.CONTAINER_NO_NAME,a.OUTBOUND_DATE,
a.COMPLETE_TIME,a.ORDER_DATE,a.TRANSPORT_MODE_CODE,a.TRANSPORT_MODE_NAME,a.SUPERVISION_MODE_CODE,a.SUPERVISION_MODE_NAME,
@@ -401,6 +402,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
<!-- 反审标记查询: OMS执行单【已反审】tab 前端传 delFlag=2 + reverseFlag=1 (与WMS四列表同口径, 两参数须成对传) -->
<if test="reverseFlag != null"> and a.reverse_flag = #{reverseFlag} </if>
</sql>
<select id="queryList" parameterType="com.mhd.oms.domain.executionStockOutOrder.repository.todo.ExecutionStockOutOrderDO" resultMap="StockOutOrderResult">
@@ -109,6 +109,11 @@
<result property="discount" column="DISCOUNT" />
<result property="isFreeManpowerFee" column="IS_FREE_MANPOWER_FEE" />
<result property="executionInOrderNumber" column="EXECUTION_IN_ORDER_NUMBER" />
<result property="reverseAuditStatus" column="REVERSE_AUDIT_STATUS" />
<result property="reverseAuditRemark" column="REVERSE_AUDIT_REMARK" />
<result property="reverseAuditBy" column="REVERSE_AUDIT_BY" />
<result property="reverseAuditByName" column="REVERSE_AUDIT_BY_NAME" />
<result property="reverseAuditTime" column="REVERSE_AUDIT_TIME" />
<!-- 饮用有效日期:queryList联查明细表聚合带出,其他查询无此列时不填充 -->
<result property="drinkDate" column="drink_date" />
</resultMap>
@@ -155,7 +160,8 @@
a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.reservation_audit_time,a.reservation_audit_name
,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.RESERVATION_ORDER_SOURCE,a.tms_order_number
,a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.STORAGE_TIME,a.in_quantity,
a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,a.execution_in_order_number
a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,a.execution_in_order_number,
a.REVERSE_AUDIT_STATUS,a.REVERSE_AUDIT_REMARK,a.REVERSE_AUDIT_BY,a.REVERSE_AUDIT_BY_NAME,a.REVERSE_AUDIT_TIME
</sql>
<sql id="joinStockInOrderPo">
@@ -239,7 +245,7 @@
and a.notice_number = #{noticeNumber}
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and a.in_order_number = #{inOrderNumber}
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="status != null ">
and a.status = #{status}
@@ -274,6 +280,10 @@
<if test="issueStatus != null">
and a.issue_status = #{issueStatus}
</if>
<!-- 反审状态过滤:入库业务单【已反审】tab 传 reverseAuditStatus=1 -->
<if test="reverseAuditStatus != null">
and a.REVERSE_AUDIT_STATUS = #{reverseAuditStatus}
</if>
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
@@ -293,7 +303,7 @@
and a.order_type_code = #{orderTypeCode}
</if>
<if test="orderTypeName != null and orderTypeName != ''">
and (a.BUSINESS_TYPE like concat('%', #{orderTypeName}, '%') or a.ORDER_TYPE_CODE like concat('%', #{orderTypeName}, '%'))
and (a.ORDER_TYPE_NAME like concat('%', #{orderTypeName}, '%') or a.BUSINESS_TYPE like concat('%', #{orderTypeName}, '%') or a.ORDER_TYPE_CODE like concat('%', #{orderTypeName}, '%'))
</if>
<if test="supplierId != null ">
and a.supplier_id = #{supplierId}
@@ -582,6 +592,19 @@
select WAREHOUSE_CODE from "NGWL_TEST_SYSTEM".WAREHOUSE where 1 = 1 and DEL_FLAG = 1 and WAREHOUSE_ID = #{id} limit 1
</select>
<!-- 本地跨库直查仓库信息: 下发/保存等流程 Feign 获取仓库信息失败/降级时兜底(与 system 服务同库同表)。
注意不含 STOCK_LOCK_MODE(冻结功能列, 各环境库结构不一致, 兜底路径不依赖冻结功能的列;
stockLockMode 走 Feign 正常路径获取, 兜底时为 null 即默认"分配库存冻结"模式) -->
<select id="getWarehouseInfoFallback" parameterType="java.lang.Long" resultType="com.mhd.system.api.domain.WarehouseFeignPO">
select WAREHOUSE_CODE as warehouseCode,
WAREHOUSE_NAME as warehouseName,
ORDER_NO_GENERATE_RULE as orderNoGenerateRule,
OUT_ORDER_NO_PREFIX as outOrderNoPrefix,
SAMPLE_OUT_ORDER_NO_PREFIX as sampleOutOrderNoPrefix
from "NGWL_TEST_SYSTEM".WAREHOUSE
where 1 = 1 and DEL_FLAG = 1 and WAREHOUSE_ID = #{id} limit 1
</select>
<!-- 入仓通知单打印-表头查询 -->
<select id="queryNoticePrint" resultMap="StockInOrderResult">
@@ -117,6 +117,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="businessPriceWay" column="BUSINESS_PRICE_WAY" />
<result property="discount" column="DISCOUNT" />
<result property="totalOutboundQuantity" column="TOTAL_OUTBOUND_QUANTITY" />
<result property="reverseStatus" column="REVERSE_STATUS" />
<result property="reverseBy" column="REVERSE_BY" />
<result property="reverseByName" column="REVERSE_BY_NAME" />
<result property="reverseTime" column="REVERSE_TIME" />
<result property="reverseRemark" column="REVERSE_REMARK" />
</resultMap>
@@ -136,7 +141,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.tms_order_number,
a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.RESERVATION_ORDER_SOURCE,a.OUTBOUND_TIME,a.RETURN_QUANTITY,a.DELIVERY_NAME,a.CUSTOMER_NUMBER,a.INVOICE_NUMBER,a.RETURN_ORDER_NUMBER,a.TOTAL_AMOUNT,
a.ROUTE,a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,a.execution_out_order_number,a.LINE_CODE,a.LINE_NAME,a.SHUTTLE_NO,
a.TOTAL_WAREHOUSE_RENT,a.BUSINESS_CHARGE_TYPE,a.BUSINESS_PRICE_WAY,a.DISCOUNT
a.TOTAL_WAREHOUSE_RENT,a.BUSINESS_CHARGE_TYPE,a.BUSINESS_PRICE_WAY,a.DISCOUNT,
a.REVERSE_STATUS,a.REVERSE_BY,a.REVERSE_BY_NAME,a.REVERSE_TIME,a.REVERSE_REMARK
</sql>
@@ -178,11 +184,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 出库状态: 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中-->
and a.status IN (3, 4, 5, 6, 7, 8)
</when>
<when test="status == -2 "> <!-- 已反审 -->
<!-- 反审后单据回退为 1-已创建 且打上反审标记, 与【已创建】页签互斥 -->
and a.status = 1 and a.reverse_status = 1
</when>
<when test="status == 1 "> <!-- 已创建: 排除已反审的单据(已划归【已反审】页签) -->
and a.status = 1 and (a.reverse_status is null or a.reverse_status = 0)
</when>
<otherwise>
and a.status = #{status}
</otherwise>
</choose>
</if>
<if test="reverseStatus != null ">
and a.reverse_status = #{reverseStatus}
</if>
<!-- 出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭 -->
<if test="gtStatus != null ">
and a.status &gt; #{gtStatus}
@@ -157,6 +157,14 @@ public class HandoverTaskOrderApplicationService {
return handoverTaskOrderDomainService.getInfo(outTaskOrderId);
}
/**
* 获取交接作业单归档详情(已反审): 反审时交接单已软删, 已反审tab 查看归档详情
*/
public HandoverTaskOrderPO getReverseInfo(Long outTaskOrderId)
{
return handoverTaskOrderDomainService.getReverseInfo(outTaskOrderId);
}
/**
* 按作业单号获取交接作业单详细信息PDA
* 用于下发任务(taskType=7) trackingNumber 对应交接作业单的 taskNumber
@@ -2,9 +2,12 @@ package com.mhd.wms.application.service.inMaterialDetail;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.inMaterialDetail.repository.po.InMaterialDetailExportPO;
import com.mhd.wms.domain.inMaterialDetail.repository.po.InMaterialDetailPO;
import com.mhd.wms.domain.inMaterialDetail.repository.po.InMaterialDetailWithOrderPO;
import com.mhd.wms.domain.inMaterialDetail.repository.todo.InMaterialDetailDO;
import com.mhd.wms.domain.inMaterialDetail.service.InMaterialDetailDomainService;
import com.mhd.wms.domain.overStock.repository.todo.QueryOrderOverStockDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -39,6 +42,51 @@ public class InMaterialDetailApplicationService {
return inMaterialDetailDomainService.queryList(inMaterialDetailDO);
}
/**
* 入库明细查询关联入库单只统计已入库(5)单据
*/
public List<InMaterialDetailWithOrderPO> queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
queryOrderOverStockDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return inMaterialDetailDomainService.queryInOrderDetailList(queryOrderOverStockDO);
}
/**
* 入库明细导出专用列集口径同 queryInOrderDetailList不分页
*/
public List<InMaterialDetailExportPO> exportInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) {
List<InMaterialDetailExportPO> list = inMaterialDetailDomainService.exportInOrderDetailList(setDataPermission(queryOrderOverStockDO));
// 货物种类=挂载分类的父级分类名称material_classify_name为分类路径("食品,饮料")取倒数第二段
// 仅一级分类(无父级)时取自身名称
for (InMaterialDetailExportPO po : list) {
String names = po.getMaterialClassifyName();
if (names != null && names.contains(",")) {
String[] parts = names.split(",");
po.setMaterialClassifyName(parts[parts.length - 2].trim());
}
}
return list;
}
/**
* 数据权限非平台超管(1)按登录人一级组织过滤
*/
private QueryOrderOverStockDO setDataPermission(QueryOrderOverStockDO queryOrderOverStockDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
queryOrderOverStockDO.setTopOrganizationId(topOrganizationId);
}
}
return queryOrderOverStockDO;
}
/**
* 新增物料明细
@@ -167,7 +167,11 @@ public class InvestigationManageApplicationService {
}
List<InvestigetionManageDetailPO> detailList = investigationManagePO.getInvestigetionManageDetailList();
// 物料编码相同的明细排在一起展示稳定排序同编码内保持原顺序仅排序不聚合各条明细独立
detailList.sort(Comparator.comparing(InvestigetionManageDetailPO::getMaterialCode,
Comparator.nullsLast(Comparator.naturalOrder())));
// 性能优化批量获取批次属性避免N+1查询问题
// 1. 收集所有唯一的materialBaseInfoId
Set<Long> materialBaseInfoIdSet = detailList.stream()
@@ -236,8 +240,9 @@ public class InvestigationManageApplicationService {
if (materialBaseInfoId != null && batchDetailMap.containsKey(materialBaseInfoId)) {
List<BatchDetailFeignPO> batchDetailFeignPOList = batchDetailMap.get(materialBaseInfoId);
// 用于跟踪已添加到列表中的batchDetailId
// 用于跟踪已添加到列表中的batchDetailIdbatchDetailId为空的配置行改用标签去重不再丢弃
Set<Long> addedBatchDetailIds = new HashSet<>();
Set<String> addedLabelKeys = new HashSet<>();
for (BatchDetailFeignPO batchDetailFeignPO : batchDetailFeignPOList) {
MaterialMoreDetailPO materialMoreDetailPO = new MaterialMoreDetailPO();
@@ -249,40 +254,44 @@ public class InvestigationManageApplicationService {
materialMoreDetailPO.setAttributeOption(batchDetailFeignPO.getAttributeOption());
materialMoreDetailPO.setRemark(batchDetailFeignPO.getRemark());
// 确保添加到列表中使用batchDetailId来避免重复
// 确保添加到列表中batchDetailId+标签双重去重batchDetailId为空的配置行也保留
Long batchDetailId = batchDetailFeignPO.getBatchDetailId();
if (batchDetailId != null && !addedBatchDetailIds.contains(batchDetailId)) {
String labelKey = batchDetailFeignPO.getBatchLabels() == null ? "" : batchDetailFeignPO.getBatchLabels().trim();
boolean duplicated = addedLabelKeys.contains(labelKey)
|| (batchDetailId != null && addedBatchDetailIds.contains(batchDetailId));
if (!duplicated) {
materialMoreDetailList.add(materialMoreDetailPO);
addedBatchDetailIds.add(batchDetailId);
addedLabelKeys.add(labelKey);
if (batchDetailId != null) {
addedBatchDetailIds.add(batchDetailId);
}
}
// 根据fieldName或batchLabels从库存表中获取对应的字段值
if (materialInventoryPO != null) {
String fieldValue = null;
String usedFieldName = null;
// 优先使用fieldName如果存在
if (StringUtils.isNotBlank(batchDetailFeignPO.getFieldName())) {
usedFieldName = batchDetailFeignPO.getFieldName();
String usedFieldName = batchDetailFeignPO.getFieldName();
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
log.info("批次属性 batchDetailId={}, fieldName={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), usedFieldName, fieldValue);
}
// 如果fieldName为空尝试根据batchLabels映射字段名
else if (StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
}
// fieldName没取到值时回退按batchLabels映射字段名再取一次修复fieldName配置失效导致值永远为空
if (fieldValue == null && StringUtils.isNotBlank(batchDetailFeignPO.getBatchLabels())) {
String fieldNameByLabel = getFieldNameByBatchLabel(batchDetailFeignPO.getBatchLabels());
if (StringUtils.isNotBlank(fieldNameByLabel)) {
usedFieldName = fieldNameByLabel;
fieldValue = getFieldValueByFieldName(materialInventoryPO, usedFieldName);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
usedFieldName, fieldValue);
fieldValue = getFieldValueByFieldName(materialInventoryPO, fieldNameByLabel);
log.info("批次属性 batchDetailId={}, batchLabels={}, 映射字段名={}, 从库存表获取到的值={}",
batchDetailFeignPO.getBatchDetailId(), batchDetailFeignPO.getBatchLabels(),
fieldNameByLabel, fieldValue);
}
}
// 只有当获取到值时才更新attributeValue
if (fieldValue != null) {
materialMoreDetailPO.setAttributeValue(fieldValue);
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
log.info("设置更多属性:batchDetailId={}, batchLabels={}, attributeValue={}",
materialMoreDetailPO.getBatchDetailId(), materialMoreDetailPO.getBatchLabels(),
materialMoreDetailPO.getAttributeValue());
}
}
@@ -306,22 +315,29 @@ public class InvestigationManageApplicationService {
return null;
}
// 批次标签到字段名的映射关系
Map<String, String> labelToFieldNameMap = new HashMap<>();
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("Invoice No", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
// 批次标签到字段名的映射关系LinkedHashMap保证匹配优先级稳定长key放前面避免短标签模糊匹配被抢先误匹配
Map<String, String> labelToFieldNameMap = new LinkedHashMap<>();
labelToFieldNameMap.put("Batch Ref NO's", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("Invoice No.", "invoiceNo");
labelToFieldNameMap.put("发票号", "invoiceNo");
labelToFieldNameMap.put("Batch Ref NO", "batchRefNo");
labelToFieldNameMap.put("批次参考号", "batchRefNo");
labelToFieldNameMap.put("Sheet Ref NO's", "sheetRefNo");
labelToFieldNameMap.put("Sheet Ref NO", "sheetRefNo");
labelToFieldNameMap.put("单据参考号", "sheetRefNo");
labelToFieldNameMap.put("箱号/卡板号", "boxPalletNo");
labelToFieldNameMap.put("箱号", "boxPalletNo");
labelToFieldNameMap.put("卡板号", "boxPalletNo");
labelToFieldNameMap.put("Batch Number", "batchNumber");
labelToFieldNameMap.put("Production Date", "productionDate");
labelToFieldNameMap.put("生产日期", "productionDate");
labelToFieldNameMap.put("Expiry Date", "expiryDate");
labelToFieldNameMap.put("EXP Date", "expiryDate");
labelToFieldNameMap.put("过期日期", "expiryDate");
labelToFieldNameMap.put("Batch No", "batchNumber");
labelToFieldNameMap.put("批次号", "batchNumber");
labelToFieldNameMap.put("入库日期", "createTime");
labelToFieldNameMap.put("入库时间", "createTime");
labelToFieldNameMap.put("存货日期", "inventoryDate");
labelToFieldNameMap.put("扩展字段1", "extAttr1");
labelToFieldNameMap.put("扩展字段2", "extAttr2");
@@ -334,14 +350,16 @@ public class InvestigationManageApplicationService {
return fieldName;
}
// 模糊匹配包含关系
// 模糊匹配包含关系多个key命中时取最长的key保证同一标签映射结果稳定
String bestMatchKey = null;
for (Map.Entry<String, String> entry : labelToFieldNameMap.entrySet()) {
if (batchLabel.contains(entry.getKey()) || entry.getKey().contains(batchLabel)) {
return entry.getValue();
if (bestMatchKey == null || entry.getKey().length() > bestMatchKey.length()) {
bestMatchKey = entry.getKey();
}
}
}
return null;
return bestMatchKey != null ? labelToFieldNameMap.get(bestMatchKey) : null;
}
/**

Some files were not shown because too many files have changed in this diff Show More