Merge branch 'dev' into feature/dev-0729

This commit is contained in:
王奎兴
2026-08-10 18:14:55 +08:00
15 changed files with 598 additions and 86 deletions
@@ -234,7 +234,7 @@ public class ReviewOrderApplicationService {
}
db.setPendingReviewQty(pending.subtract(qty));
db.setReviewedQty(reviewed.add(qty));
// 同步页面传入的重量/体积/面积
// 同步页面传入的重量/体积/面积/尺寸
if (i.getNetWeightKg() != null) {
db.setNetWeightKg(i.getNetWeightKg());
}
@@ -247,6 +247,9 @@ public class ReviewOrderApplicationService {
if (i.getAreaSqm() != null) {
db.setAreaSqm(i.getAreaSqm());
}
if (i.getSize() != null) {
db.setSize(i.getSize());
}
fillOperator(db);
reviewMaterialDetailMapper.updateById(db);
}
@@ -288,7 +291,7 @@ public class ReviewOrderApplicationService {
db.setReviewedQty(reviewed.subtract(qty));
db.setPendingReviewQty(pending.add(qty));
db.setCancelQty(cancel.add(qty));
// 同步页面传入的重量/体积/面积
// 同步页面传入的重量/体积/面积/尺寸
if (i.getNetWeightKg() != null) {
db.setNetWeightKg(i.getNetWeightKg());
}
@@ -301,6 +304,9 @@ public class ReviewOrderApplicationService {
if (i.getAreaSqm() != null) {
db.setAreaSqm(i.getAreaSqm());
}
if (i.getSize() != null) {
db.setSize(i.getSize());
}
fillOperator(db);
reviewMaterialDetailMapper.updateById(db);
}
@@ -337,16 +343,16 @@ public class ReviewOrderApplicationService {
// 与出库单「复核确认」一致:复核数量与拣货数量不一致时生成复核异常单(FHYC)
genOutOrderAbnormalAfterReviewConfirm(reviewOrderId);
// 校验:复核确认前,已复核数量必须等于计划数量
List<ReviewMaterialDetailPO> details = reviewOrderMapper.queryDetailByReviewOrderId(reviewOrderId);
if (!CollectionUtils.isEmpty(details)) {
for (ReviewMaterialDetailPO detail : details) {
BigDecimal reviewed = nz(detail.getReviewedQty());
BigDecimal plan = nz(detail.getMaterialPlanQty());
if (reviewed.compareTo(plan) != 0) {
throw new ServiceException("该物料已复核数量不等于计划数量");
}
}
}
// List<ReviewMaterialDetailPO> details = reviewOrderMapper.queryDetailByReviewOrderId(reviewOrderId);
// if (!CollectionUtils.isEmpty(details)) {
// for (ReviewMaterialDetailPO detail : details) {
// BigDecimal reviewed = nz(detail.getReviewedQty());
// BigDecimal plan = nz(detail.getMaterialPlanQty());
// if (reviewed.compareTo(plan) != 0) {
// throw new ServiceException("该物料已复核数量不等于计划数量");
// }
// }
// }
ReviewOrder order = reviewOrderMapper.selectById(reviewOrderId);
if (order == null) {
continue;
@@ -751,8 +757,11 @@ public class ReviewOrderApplicationService {
if (i.getAreaSqm() != null) {
db.setAreaSqm(i.getAreaSqm());
}
if (i.getSize() != null) {
db.setSize(i.getSize());
}
if (qtyTouched || i.getNetWeightKg() != null || i.getGrossWeightKg() != null
|| i.getVolumeCbm() != null || i.getAreaSqm() != null) {
|| i.getVolumeCbm() != null || i.getAreaSqm() != null || i.getSize() != null) {
fillOperator(db);
reviewMaterialDetailMapper.updateById(db);
}
@@ -792,11 +801,18 @@ public class ReviewOrderApplicationService {
private void refreshReviewOrderStatus(Long reviewOrderId) {
List<ReviewMaterialDetailPO> rows = reviewOrderMapper.queryDetailByReviewOrderId(reviewOrderId);
// 业务口径:只有全部明细待复核=0 时,状态才置为 2部分复核保持 1
// 状态 3 仅在 checkConfirm 中设置
boolean allReviewed = !CollectionUtils.isEmpty(rows)
&& rows.stream().allMatch(r -> nz(r.getPendingReviewQty()).compareTo(BigDecimal.ZERO) == 0);
Integer targetStatus = allReviewed ? 2 : 1;
// ================== 旧口径:全部明细待复核=0 2部分复核保持 1 ==================
// // 业务口径:只有全部明细待复核=0 时,状态才置为 2;部分复核仍保持 1
// // 状态 3 仅在 checkConfirm 中设置。
// boolean allReviewed = !CollectionUtils.isEmpty(rows)
// && rows.stream().allMatch(r -> nz(r.getPendingReviewQty()).compareTo(BigDecimal.ZERO) == 0);
// Integer targetStatus = allReviewed ? 2 : 1;
// ================== 新口径:部分复核/全部复核完未确认均置 复核中(2),完全未复核保持 待复核(1) ==================
// 只要有任意明细已复核数量>0(部分复核 / 全部复核完未确认)即为复核中(2);
// 完全未复核(全部已复核=0)保持待复核(1)。状态 3 仅在 checkConfirm 中设置。
boolean anyReviewed = !CollectionUtils.isEmpty(rows)
&& rows.stream().anyMatch(r -> nz(r.getReviewedQty()).compareTo(BigDecimal.ZERO) > 0);
Integer targetStatus = anyReviewed ? 2 : 1;
ReviewOrder order = reviewOrderMapper.selectById(reviewOrderId);
if (order == null) {
@@ -3,7 +3,7 @@ package com.mhd.wms.domain.inventoryAdjustmentRecord.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.oss.ServiceException;
import com.mhd.common.core.exception.ServiceException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mhd.common.core.constant.SnowFlakeConstants;
import com.mhd.common.core.domain.po.UserPo;
@@ -175,7 +175,7 @@ public class InventoryAdjustmentRecordDomainService {
}
materialInventory.setAllocationQuantity(materialInventory.getAllocationQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
throw new ServiceException("可用数量调整之后不能小于0");
throw new ServiceException("调整之后可用数量不能小于0");
}
}
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
@@ -231,7 +231,7 @@ public class InventoryAdjustmentRecordDomainService {
}
materialInventory.setAllocationQuantity(materialInventory.getAllocationQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
throw new ServiceException("可用数量调整之后不能小于0");
throw new ServiceException("调整之后可用数量不能小于0");
}
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
@@ -292,7 +292,7 @@ public class InventoryAdjustmentRecordDomainService {
//推送oms库存调整记录
try{
// 当仓库启用 oms 才进行推送
if (warehousePO.getIsEnable() == 1) {
if (ObjectUtil.isNotNull(warehousePO) && warehousePO.getIsEnable() == 1) {
Boolean pushSuccess = pushOms(materialInventory, inventoryAdjustmentRecordDO);
if (!pushSuccess) {
throw new ServiceException("库存调整推送OMS失败,请稍后重试");
@@ -78,7 +78,8 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
if ("hz".equals(queryRule)) {
return materialInventoryMapper.queryListByHz(materialInventoryDO);
} else if ("hzwl".equals(queryRule)) { // 货主查询
return materialInventoryMapper.queryListByHzWl(materialInventoryDO);
return materialInventoryMapper.queryListByHz(materialInventoryDO);
// return materialInventoryMapper.queryListByHzWl(materialInventoryDO);
} else if ("wl".equals(queryRule)) { // 物料查询
return materialInventoryMapper.queryListByWl(materialInventoryDO);
} else if ("kw".equals(queryRule)) {
@@ -406,7 +406,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID order by sort_order, a.update_time desc
GROUP BY a.SHIPPER_ID,a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID order by sort_order, a.update_time desc
</select>
<select id="queryListByKw" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
@@ -429,37 +429,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from material_inventory a
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
inner join (
select material_base_info_id, warehouse_id, warehouse_code, warehouse_name,
storage_section_id, storage_code, storage_name,
storage_location_id, storage_location_code, storage_location_name
from (
select mi.material_base_info_id, mi.warehouse_id, mi.warehouse_code, mi.warehouse_name,
mi.storage_section_id, mi.storage_code, mi.storage_name,
mi.storage_location_id, mi.storage_location_code, mi.storage_location_name,
row_number() over (partition by mi.material_base_info_id order by mi.create_time desc, mi.material_inventory_id desc) as wl_rn
from material_inventory mi
left join material_base_info b on mi.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1Mi"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
) wl_ranked where wl_ranked.wl_rn = 1
) loc on loc.material_base_info_id = a.material_base_info_id
select material_base_info_id, warehouse_id, warehouse_code, warehouse_name,
storage_section_id, storage_code, storage_name,
storage_location_id, storage_location_code, storage_location_name
from (
select mi.material_base_info_id, mi.warehouse_id, mi.warehouse_code, mi.warehouse_name,
mi.storage_section_id, mi.storage_code, mi.storage_name,
mi.storage_location_id, mi.storage_location_code, mi.storage_location_name,
row_number() over (partition by mi.material_base_info_id, mi.warehouse_id order by mi.create_time desc, mi.material_inventory_id desc) as wl_rn
from material_inventory mi
left join material_base_info b on mi.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1Mi"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
) wl_ranked where wl_ranked.wl_rn = 1
) loc on loc.material_base_info_id = a.material_base_info_id and loc.warehouse_id = a.warehouse_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID,
loc.warehouse_id, loc.warehouse_code, loc.warehouse_name,
loc.storage_section_id, loc.storage_code, loc.storage_name,
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name order by sort_order, a.update_time desc
GROUP BY a.MATERIAL_BASE_INFO_ID, a.WAREHOUSE_ID,
loc.warehouse_id, loc.warehouse_code, loc.warehouse_name,
loc.storage_section_id, loc.storage_code, loc.storage_name,
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name order by sort_order, a.update_time desc
</select>
<!-- 按物料+过期日期汇总:相同物料+相同过期日期合并,不同过期日期分开 -->
<select id="queryListByWlExpiry" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
a.material_base_info_id, a.expiry_date, a.shipper_id, a.shipper_code, a.shipper_name,
a.organization_id, a.organization_name, a.top_organization_id,
a.material_base_info_id, a.expiry_date, a.shipper_id,
MAX(a.shipper_code) AS shipper_code, MAX(a.shipper_name) AS shipper_name,
a.organization_id, MAX(a.organization_name) AS organization_name, a.top_organization_id,
MAX(a.warehouse_id) AS warehouse_id, MAX(a.warehouse_code) AS warehouse_code, MAX(a.warehouse_name) AS warehouse_name,
MAX(a.storage_section_id) AS storage_section_id, MAX(a.storage_code) AS storage_code, MAX(a.storage_name) AS storage_name,
MAX(a.storage_location_id) AS storage_location_id, MAX(a.storage_location_code) AS storage_location_code, MAX(a.storage_location_name) AS storage_location_name,
@@ -479,8 +480,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
MAX(a.batch_ref_no) AS batch_ref_no, MAX(a.sheet_ref_no) AS sheet_ref_no, MAX(a.box_pallet_no) AS box_pallet_no,
MAX(a.bar_code) AS inv_bar_code,
MAX(a.in_order_number) AS in_order_number, MAX(a.lot_number) AS lot_number,
b.specification_model,
b.material_code, b.material_name,
MAX(b.specification_model) AS specification_model,
MAX(b.material_code) AS material_code, MAX(b.material_name) AS material_name,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
from material_inventory a
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
@@ -488,9 +489,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id, a.shipper_code, a.shipper_name,
a.organization_id, a.organization_name, a.top_organization_id,
b.material_code, b.material_name, b.specification_model
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id,
a.organization_id, a.top_organization_id
order by sort_order, MAX(a.update_time) desc
</select>
@@ -531,28 +531,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- ============ 按货主+物料+仓库+单位 汇总(库存查询第三个页签) ============ -->
<!-- SELECT 列:需求字段,全部聚合;包装单位优先库存表,回退物料基础信息表 -->
<sql id="selectMaterialInventoryPoByHzWlUnit">
a.shipper_id, a.shipper_code, a.shipper_name,
b.material_base_info_id, b.material_code, b.material_name, b.SPECIFICATION_MODEL,
a.warehouse_id, a.warehouse_code, a.warehouse_name,
a.organization_id, a.organization_name, a.top_organization_id,
MAX(b.material_type) AS material_type,
MAX(b.material_type_name) AS material_type_name,
MAX(b.bar_code) AS bar_code,
MAX(nvl(a.unit_name, b.unit_name)) AS unit_name,
MAX(b.pack_id) AS pack_id,
MAX(b.pack_code) AS pack_code,
MAX(b.pack_name) AS pack_name,
MAX(a.unit) AS unit,
IFNULL(SUM(a.freeze_quantity), 0) AS freeze_quantity,
IFNULL(SUM(a.inventory_quantity), 0) AS inventory_quantity,
IFNULL(SUM(a.allocation_quantity), 0) AS allocation_quantity,
IFNULL(SUM(a.area), 0) AS area,
IFNULL(SUM(a.NET_WEIGHT), 0) AS NET_WEIGHT,
IFNULL(SUM(a.GROSS_WEIGHT), 0) AS GROSS_WEIGHT,
IFNULL(SUM(a.VOLUME), 0) AS VOLUME,
MIN(a.create_time) AS create_time, -- 新增:首次入库时间
MAX(a.update_time) AS update_time,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
a.shipper_id,
MAX(a.shipper_code) AS shipper_code,
MAX(a.shipper_name) AS shipper_name,
MAX(b.material_base_info_id) AS material_base_info_id,
MAX(b.material_code) AS material_code,
MAX(b.material_name) AS material_name,
MAX(b.SPECIFICATION_MODEL) AS SPECIFICATION_MODEL,
a.warehouse_id,
MAX(a.warehouse_code) AS warehouse_code,
MAX(a.warehouse_name) AS warehouse_name,
a.organization_id,
MAX(a.organization_name) AS organization_name,
a.top_organization_id,
MAX(b.material_type) AS material_type,
MAX(b.material_type_name) AS material_type_name,
MAX(b.bar_code) AS bar_code,
MAX(nvl(a.unit_name, b.unit_name)) AS unit_name,
MAX(b.pack_id) AS pack_id,
MAX(b.pack_code) AS pack_code,
MAX(b.pack_name) AS pack_name,
MAX(a.unit) AS unit,
IFNULL(SUM(a.freeze_quantity), 0) AS freeze_quantity,
IFNULL(SUM(a.inventory_quantity), 0) AS inventory_quantity,
IFNULL(SUM(a.allocation_quantity), 0) AS allocation_quantity,
IFNULL(SUM(a.area), 0) AS area,
IFNULL(SUM(a.NET_WEIGHT), 0) AS NET_WEIGHT,
IFNULL(SUM(a.GROSS_WEIGHT), 0) AS GROSS_WEIGHT,
IFNULL(SUM(a.VOLUME), 0) AS VOLUME,
MIN(a.create_time) AS create_time,
MAX(a.update_time) AS update_time,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
</sql>
<select id="queryListByHzWlUnit"
@@ -570,10 +579,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and IFNULL(a.inventory_quantity, 0) &gt; 0
</if>
</where>
GROUP BY a.shipper_id, a.shipper_code, a.shipper_name,
b.material_base_info_id, b.material_code, b.material_name, b.SPECIFICATION_MODEL,
a.warehouse_id, a.warehouse_code, a.warehouse_name,
a.organization_id, a.organization_name, a.top_organization_id
GROUP BY a.shipper_id,
b.material_code,
a.warehouse_id,
a.organization_id, a.top_organization_id
ORDER BY sort_order, MAX(a.update_time) DESC
</select>
@@ -587,7 +596,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.SHIPPER_ID order by sort_order, a.update_time desc
GROUP BY a.SHIPPER_ID, a.WAREHOUSE_ID order by sort_order, a.update_time desc
</select>
<resultMap type="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO" id="MaterialQueryListResult">