feat(盘点单创建):修改查询逻辑1.2

This commit is contained in:
chengzhaofeng 2024-12-24 19:31:51 +08:00
parent 3972350fc4
commit 1f440a4bac
4 changed files with 99 additions and 21 deletions

View File

@ -345,6 +345,14 @@ public class ZWmsInventoryCheckSnapshot extends Model<ZWmsInventoryCheckSnapshot
@TableField(exist = false)
private BigDecimal qtyOnHandActual;
/**
* 实盘erp仓库
*/
@ApiModelProperty(value="erp仓库")
@TableField(exist = false)
private String erpStorageLocationActual;
/**
* 实盘数量
*/

View File

@ -8,10 +8,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.iep.prd.entity.Item;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckCount;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckSnapshot;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryCheckCountMapper;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryCheckSnapshotMapper;
import com.foreverwin.mom.wms.service.WmsItemService;
import com.foreverwin.mom.wms.service.ZWmsInventoryCheckCountService;
@ -41,33 +43,38 @@ import java.util.stream.Collectors;
public class ZWmsInventoryCheckSnapshotServiceImpl extends ServiceImpl<ZWmsInventoryCheckSnapshotMapper, ZWmsInventoryCheckSnapshot> implements ZWmsInventoryCheckSnapshotService {
private final ZWmsInventoryCheckCountService zWmsInventoryCheckCountService;
private final ZWmsInventoryCheckCountMapper zWmsInventoryCheckCountMapper;
private final WmsItemService wmsItemService;
@Override
public Page<ZWmsInventoryCheckSnapshot> selectSnapshotInfoDifference(Page<ZWmsInventoryCheckSnapshot> page,
ZWmsInventoryCheckSnapshot zWmsInventoryCheckSnapshot) {
List<ZWmsInventoryCheckSnapshot> result = getzWmsInventoryCheckSnapshots(zWmsInventoryCheckSnapshot);
// 根据传入进来的 page,对 result 进行分页数据处理
long current = page.getCurrent();
long size = page.getSize();
page.setTotal(result.size());
if (current > 1) {
int fromIndex = (int) ((current - 1) * size);
int toIndex = (int) (current * size);
if (toIndex > result.size()) {
toIndex = result.size();
}
result = result.subList(fromIndex, toIndex);
} else {
int toIndex = (int) size;
if (toIndex > result.size()) {
toIndex = result.size();
}
result = result.subList(0, toIndex);
if (StrUtil.isBlank(zWmsInventoryCheckSnapshot.getCheckNo())) {
throw BusinessException.build("盘点单号不能为空!");
}
page.setRecords(result);
return page;
return zWmsInventoryCheckCountMapper.getDifference(page, zWmsInventoryCheckSnapshot);
// List<ZWmsInventoryCheckSnapshot> result = getzWmsInventoryCheckSnapshots(zWmsInventoryCheckSnapshot);
// // 根据传入进来的 page,对 result 进行分页数据处理
// long current = page.getCurrent();
// long size = page.getSize();
// page.setTotal(result.size());
// if (current > 1) {
// int fromIndex = (int) ((current - 1) * size);
// int toIndex = (int) (current * size);
// if (toIndex > result.size()) {
// toIndex = result.size();
// }
// result = result.subList(fromIndex, toIndex);
// } else {
// int toIndex = (int) size;
// if (toIndex > result.size()) {
// toIndex = result.size();
// }
// result = result.subList(0, toIndex);
// }
// page.setRecords(result);
// return page;
}
@NotNull

View File

@ -1,8 +1,11 @@
package com.foreverwin.mom.wms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckCount;
import com.foreverwin.mom.wms.entity.ZWmsInventoryCheckSnapshot;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 盘点库存快照表
@ -12,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ZWmsInventoryCheckCountMapper extends BaseMapper<ZWmsInventoryCheckCount> {
Page<ZWmsInventoryCheckSnapshot> getDifference(Page<ZWmsInventoryCheckSnapshot> page, @Param("param") ZWmsInventoryCheckSnapshot zWmsInventoryCheckSnapshot);
}

View File

@ -53,4 +53,63 @@
<result property="dateUpdate" column="DATE_UPDATE"/>
<result property="updater" column="UPDATER"/>
</resultMap>
<select id="getDifference" resultType="com.foreverwin.mom.wms.entity.ZWmsInventoryCheckSnapshot">
select
INVENTORY_ID,
ITEM,
DESCRIPTION,
erpStorageLocation,
wmsStorageBinSnapShot,
qtyOnHandSnapShot,
erpStorageLocationActual,
wmsStorageBinActual,
qtyOnHandActual,
differenceType
from (select t1.CHECK_NO
, t1.INVENTORY_ID -- 条码
, t1.ITEM -- 物料
, i1.DESCRIPTION -- 物料描述
, t1.ERP_STORAGE_LOCATION erpStorageLocation
, t1.WMS_STORAGE_BIN wmsStorageBinSnapShot -- 快照货格
, t1.QTY_ON_HAND qtyOnHandSnapShot -- 快照数量
, m1.ERP_STORAGE_LOCATION erpStorageLocationActual
, m1.WMS_STORAGE_BIN wmsStorageBinActual -- 实盘货格
, m1.QTY_ON_HAND qtyOnHandActual -- 实盘数量
, case
when m1.INVENTORY_ID is null then '3' -- 库存快照存在但实盘不存在
when m1.ERP_STORAGE_LOCATION <> t1.ERP_STORAGE_LOCATION then '4' -- 货位不同
when m1.QTY_ON_HAND <> t1.QTY_ON_HAND then '1' -- 数量不同
when m1.QTY_ON_HAND = t1.QTY_ON_HAND and m1.ERP_STORAGE_LOCATION = t1.ERP_STORAGE_LOCATION
then '5' -- 数量相同货位相同
else '0' -- 其他
end differenceType
from wms.z_wms_inventory_check_snapshot t1
left join wms.z_wms_inventory_check_count m1
on m1.CHECK_NO = t1.CHECK_NO and m1.INVENTORY_ID = t1.INVENTORY_ID
left join wip.item i1
on i1.ITEM = t1.ITEM and i1.SITE = t1.SITE
where t1.CHECK_NO = #{param.checkNo}
union
select t2.CHECK_NO
, t2.INVENTORY_ID -- 条码
, t2.ITEM -- 物料
, i2.DESCRIPTION -- 物料描述
, null erpStorageLocation -- 快照仓库
, null wmsStorageBinSnapShot -- 快照货格
, null qtyOnHandSnapShot -- 快照数量
, t2.ERP_STORAGE_LOCATION erpStorageLocationActual
, t2.WMS_STORAGE_BIN_BO wmsStorageBinActual -- 实盘货格
, t2.QTY_ON_HAND qtyOnHandActual -- 实盘数量
, '2' differenceType -- 实盘存在快照不存在
from wms.z_wms_inventory_check_count t2
left join wms.z_wms_inventory_check_snapshot m2
on m2.CHECK_NO = t2.CHECK_NO and m2.INVENTORY_ID = t2.INVENTORY_ID
left join wip.item i2
on i2.ITEM = t2.ITEM and i2.SITE = t2.SITE
where t2.CHECK_NO = #{param.checkNo}
and m2.INVENTORY_ID is null) t where 1 = 1
<if test="param.differenceType != null and param.differenceType != ''">
and t.differenceType = #{param.differenceType}
</if>
</select>
</mapper>