盘点模块修改

This commit is contained in:
2025-09-15 15:17:16 +08:00
parent 8c6cc08cac
commit 496547211b
12 changed files with 273 additions and 194 deletions

View File

@@ -55,11 +55,15 @@ public class InventoryMatchScanController extends BaseController {
*/ */
@GetMapping("/countList") @GetMapping("/countList")
public TableDataInfo countList(InventoryMatchScan matchScan) { public TableDataInfo countList(InventoryMatchScan matchScan) {
// 开启分页
startPage(); startPage();
// 调用 service 层查询数据
List<RkInfoMatchVO> list = inventoryMatchScanService.selectMatchScanCountList(matchScan); List<RkInfoMatchVO> list = inventoryMatchScanService.selectMatchScanCountList(matchScan);
// 返回分页后的结果
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 根据任务名称分页查询盘点结果 * 根据任务名称分页查询盘点结果
* @param dto * @param dto

View File

@@ -60,12 +60,17 @@ public class InventoryMatchScanServiceImpl implements InventoryMatchScanService
@Override @Override
public List<RkInfoMatchVO> selectMatchScanCountList(InventoryMatchScan param) { public List<RkInfoMatchVO> selectMatchScanCountList(InventoryMatchScan param) {
// 状态=2只查扫描表中的数据
if ("2".equals(param.getStatus())) { if ("2".equals(param.getStatus())) {
return mapper.selectOnlyFromMatchScan(param); return mapper.selectOnlyFromMatchScan(param);
} else if ("1".equals(param.getStatus())) { }
String wh = taskMapper.getWhByTaskId(param.getTaskId()); // 状态=1查询指定仓库下未被扫描的库位
else if ("1".equals(param.getStatus())) {
String wh = taskMapper.getWhByTaskId(param.getTaskId()); // 根据任务ID获取仓库ID
return rkInfoMapper.getUnscannedPcodeByWh(wh, param.getTaskId()); return rkInfoMapper.getUnscannedPcodeByWh(wh, param.getTaskId());
} else { }
// 其它情况:返回扫描表和库存表的关联数据
else {
return mapper.selectJoinRkInfo(param); return mapper.selectJoinRkInfo(param);
} }
} }

View File

@@ -19,7 +19,7 @@ public class HdInventoryController {
@Autowired @Autowired
private IRkInfoService rkInfoService; private IRkInfoService rkInfoService;
@ApiModelProperty("盘点对比") @ApiModelProperty("开始匹配")
@PostMapping("/match") @PostMapping("/match")
public AjaxResult match(@RequestBody QueryDTO dto) { public AjaxResult match(@RequestBody QueryDTO dto) {

View File

@@ -80,4 +80,11 @@ public interface InventoryTaskMapper
* @param status * @param status
*/ */
void updateStatus(@Param("taskId") String taskId, @Param("status") String status); void updateStatus(@Param("taskId") String taskId, @Param("status") String status);
/**
* 根据任务ID查询场景ID
* @param taskId
* @return
*/
String selectSceneIdById(String taskId);
} }

View File

@@ -1,6 +1,5 @@
package com.zg.project.wisdom.controller; package com.zg.project.wisdom.controller;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -8,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.zg.project.wisdom.domain.dto.*; import com.zg.project.wisdom.domain.dto.*;
import com.zg.project.wisdom.domain.vo.BillGroupVO; import com.zg.project.wisdom.domain.vo.PcodeQtyVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +38,7 @@ public class RkInfoController extends BaseController
/** /**
* 查询出库,借料,待审批,撤销出入库单据主列表 * 查询出库,借料,待审批,撤销出入库单据主列表
*/ */
@PreAuthorize("@ss.hasPermi('wisdom:stock:list')") // @PreAuthorize("@ss.hasPermi('wisdom:stock:list')")
@PostMapping("/list") @PostMapping("/list")
public TableDataInfo list(@RequestBody RkInfoQueryDTO rkInfo) { public TableDataInfo list(@RequestBody RkInfoQueryDTO rkInfo) {
PageHelper.startPage(rkInfo.getPageNum(), rkInfo.getPageSize()); PageHelper.startPage(rkInfo.getPageNum(), rkInfo.getPageSize());
@@ -47,6 +46,14 @@ public class RkInfoController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
// @PreAuthorize("@ss.hasPermi('wisdom:stock:stat')")
@GetMapping("/pcode/{pcode}")
public AjaxResult listRkInfoByPcode(@PathVariable String pcode) {
List<RkInfo> rows = rkInfoService.listRkInfoByPcode(pcode);
return AjaxResult.success(rows);
}
@ApiOperation("按单据分组bill_no列表若存在出库则同时返回 bill_no_ck") @ApiOperation("按单据分组bill_no列表若存在出库则同时返回 bill_no_ck")
@PreAuthorize("@ss.hasPermi('wisdom:stock:list')") @PreAuthorize("@ss.hasPermi('wisdom:stock:list')")
@PostMapping("/bill/groups") @PostMapping("/bill/groups")

View File

@@ -0,0 +1,14 @@
// vo/PcodeQtyVO.java
package com.zg.project.wisdom.domain.vo;
import java.math.BigDecimal;
import lombok.Data;
@Data
public class PcodeQtyVO {
/** 库位码 */
private String pcode;
/** 在库总数量real_qty 之和) */
private BigDecimal totalQty;
}

View File

@@ -1,14 +1,12 @@
package com.zg.project.wisdom.mapper; package com.zg.project.wisdom.mapper;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zg.project.Inventory.domain.vo.PcdeCntVO; import com.zg.project.Inventory.domain.vo.PcdeCntVO;
import com.zg.project.Inventory.domain.vo.RkInfoMatchVO; import com.zg.project.Inventory.domain.vo.RkInfoMatchVO;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.domain.StockPhoto;
import com.zg.project.wisdom.domain.dto.RkInfoQueryDTO; import com.zg.project.wisdom.domain.dto.RkInfoQueryDTO;
import com.zg.project.wisdom.domain.vo.PcodeQtyVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
@@ -129,25 +127,22 @@ public interface RkInfoMapper
int cancelStockOut(String billNoCk); int cancelStockOut(String billNoCk);
/** /**
* 查看盘点扫描正常数据 * 查看盘点扫描正常数据(限定场景)
* @param pcdeIds
* @return
*/ */
List<RkInfo> getByPcodeIdList(List<String> pcdeIds); List<RkInfo> getByPcodeIdList(@Param("list") List<String> pcdeIds,
@Param("sceneId") String sceneId);
/** /**
* 盘点扫描未正常数据 * 查看盘点扫描未正常数据(限定场景)
* @param pcdeIds
* @return
*/ */
List<RkInfo> getMissedPcodeIds(List<String> pcdeIds); List<RkInfo> getMissedPcodeIds(@Param("list") List<String> pcdeIds,
@Param("sceneId") String sceneId);
/** /**
* 判断盘点扫描的id是否存在 * 判断盘点扫描的id在场景内是否存在
* @param id
* @return
*/ */
int existsByPcodeId(String id); int existsByPcodeId(@Param("pcodeId") String pcodeId,
@Param("sceneId") String sceneId);
/** /**
* 获取指定仓库的盘点数据 * 获取指定仓库的盘点数据
@@ -223,4 +218,7 @@ public interface RkInfoMapper
* @return * @return
*/ */
List<RkInfo> selectRkInfoByIds(@Param("ids") Long[] ids); List<RkInfo> selectRkInfoByIds(@Param("ids") Long[] ids);
List<RkInfo> listRkInfoByPcode(String pcode);
} }

View File

@@ -6,7 +6,7 @@ import com.zg.project.Inventory.domain.dto.QueryDTO;
import com.zg.project.Inventory.domain.vo.ChartDataVO; import com.zg.project.Inventory.domain.vo.ChartDataVO;
import com.zg.project.wisdom.domain.RkInfo; import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.domain.dto.*; import com.zg.project.wisdom.domain.dto.*;
import com.zg.project.wisdom.domain.vo.BillGroupVO; import com.zg.project.wisdom.domain.vo.PcodeQtyVO;
/** /**
* 库存单据主Service接口 * 库存单据主Service接口
@@ -148,4 +148,11 @@ public interface IRkInfoService
*/ */
void revertByIds(Long[] ids); void revertByIds(Long[] ids);
/**
* 按库位查询货物数量
* @param pcode
* @return
*/
List<RkInfo> listRkInfoByPcode(String pcode);
} }

View File

@@ -22,6 +22,7 @@ import com.zg.project.system.service.ISysConfigService;
import com.zg.project.wisdom.domain.AuditSignature; import com.zg.project.wisdom.domain.AuditSignature;
import com.zg.project.wisdom.domain.GysJh; import com.zg.project.wisdom.domain.GysJh;
import com.zg.project.wisdom.domain.dto.*; import com.zg.project.wisdom.domain.dto.*;
import com.zg.project.wisdom.domain.vo.PcodeQtyVO;
import com.zg.project.wisdom.mapper.AuditSignatureMapper; import com.zg.project.wisdom.mapper.AuditSignatureMapper;
import com.zg.project.wisdom.mapper.GysJhMapper; import com.zg.project.wisdom.mapper.GysJhMapper;
import com.zg.project.wisdom.utils.BillNoUtil; import com.zg.project.wisdom.utils.BillNoUtil;
@@ -737,32 +738,18 @@ public class RkInfoServiceImpl implements IRkInfoService
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void matchWithStatus(QueryDTO dto) { public void matchWithStatus(QueryDTO dto) {
List<String> pcdeIds = dto.getIds(); List<String> pcdeIds = dto.getIds();
if (pcdeIds == null || pcdeIds.isEmpty()) return; if (pcdeIds == null || pcdeIds.isEmpty()) return;
// 一、三类匹配数据 // 场景ID优先取 DTO没有就通过任务查
List<RkInfo> matchedAll = rkInfoMapper.getByPcodeIdList(pcdeIds); String sceneId = taskMapper.selectSceneIdById(dto.getTaskId());
matchedAll.forEach(r -> r.setStatus("0")); if (sceneId == null || sceneId.trim().isEmpty()) {
throw new ServiceException("匹配失败缺少场景ID");
}
List<RkInfo> missedAll = rkInfoMapper.getMissedPcodeIds(pcdeIds); // 自动盘点必须要设备ID
missedAll.forEach(r -> r.setStatus("1"));
List<String> errorIds = pcdeIds.stream()
.filter(id -> rkInfoMapper.existsByPcodeId(id) == 0)
.collect(Collectors.toList());
List<RkInfo> errorAll = errorIds.stream()
.map(id -> {
RkInfo r = new RkInfo();
r.setPcodeId(id);
r.setStatus("2");
return r;
})
.collect(Collectors.toList());
// 二、封装入库记录
String tmeStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
String deviceId = dto.getDeviceId(); String deviceId = dto.getDeviceId();
int scanType = dto.getScanType() != null ? dto.getScanType() : 0; int scanType = dto.getScanType() != null ? dto.getScanType() : 0;
String taskId = dto.getTaskId(); String taskId = dto.getTaskId();
@@ -771,7 +758,28 @@ public class RkInfoServiceImpl implements IRkInfoService
throw new ServiceException("自动盘点必须传递设备ID"); throw new ServiceException("自动盘点必须传递设备ID");
} }
// 三类数据(限定在 sceneId 内)
List<RkInfo> matchedAll = rkInfoMapper.getByPcodeIdList(pcdeIds, sceneId);
matchedAll.forEach(r -> r.setStatus("0"));
List<RkInfo> missedAll = rkInfoMapper.getMissedPcodeIds(pcdeIds, sceneId);
missedAll.forEach(r -> r.setStatus("1"));
List<String> errorIds = pcdeIds.stream()
.filter(id -> rkInfoMapper.existsByPcodeId(id, sceneId) == 0)
.collect(Collectors.toList());
List<RkInfo> errorAll = errorIds.stream().map(id -> {
RkInfo r = new RkInfo();
r.setPcodeId(id);
r.setStatus("2");
return r;
}).collect(Collectors.toList());
// 统一落表
String tmeStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
List<InventoryMatchScan> toSave = new ArrayList<>(); List<InventoryMatchScan> toSave = new ArrayList<>();
for (RkInfo r : matchedAll) { for (RkInfo r : matchedAll) {
toSave.add(buildScanRecord(taskId, r.getPcodeId(), "0", deviceId, tmeStr, scanType)); toSave.add(buildScanRecord(taskId, r.getPcodeId(), "0", deviceId, tmeStr, scanType));
} }
@@ -786,7 +794,9 @@ public class RkInfoServiceImpl implements IRkInfoService
matchScanMapper.insertBatch(toSave); matchScanMapper.insertBatch(toSave);
} }
taskMapper.updateStatus(taskId, "1"); if (taskId != null && !taskId.trim().isEmpty()) {
taskMapper.updateStatus(taskId, "1"); // 已完成
}
} }
private InventoryMatchScan buildScanRecord(String taskId, String pcode, String status, private InventoryMatchScan buildScanRecord(String taskId, String pcode, String status,
@@ -935,4 +945,9 @@ public class RkInfoServiceImpl implements IRkInfoService
} }
} }
@Override
public List<RkInfo> listRkInfoByPcode(String pcode) {
return rkInfoMapper.listRkInfoByPcode(pcode);
}
} }

View File

@@ -197,21 +197,19 @@
resultType="com.zg.project.Inventory.domain.vo.RkInfoMatchVO"> resultType="com.zg.project.Inventory.domain.vo.RkInfoMatchVO">
SELECT SELECT
r.pcode AS rkPcode, r.pcode AS rkPcode,
r.real_qty AS realQty COALESCE(SUM(r.real_qty), 0) AS realQty
FROM rk_info r
WHERE r.pcode_id IN (
SELECT DISTINCT i.pcode
FROM inventory_match_scan i FROM inventory_match_scan i
LEFT JOIN rk_info r ON i.pcode = r.pcode_id
<where> <where>
<if test="taskId != null and taskId != ''"> <if test="taskId != null and taskId != ''">AND i.task_id = #{taskId}</if>
AND i.task_id = #{taskId} <if test="deviceId != null and deviceId != ''">AND i.device_id = #{deviceId}</if>
</if> <if test="status != null and status != ''">AND i.status = #{status}</if>
<if test="deviceId != null and deviceId != ''">
AND i.device_id = #{deviceId}
</if>
<if test="status != null and status != ''">
AND i.status = #{status}
</if>
</where> </where>
ORDER BY i.tme DESC )
GROUP BY r.pcode
ORDER BY MAX(r.create_time) DESC
</select> </select>
</mapper> </mapper>

View File

@@ -85,6 +85,14 @@
where id = #{taskId} where id = #{taskId}
</select> </select>
<select id="selectSceneIdById" parameterType="string" resultType="java.lang.String">
SELECT scene_id
FROM inventory_task
WHERE id = #{id}
AND is_delete = '0'
LIMIT 1
</select>
<insert id="insertInventoryTask" parameterType="InventoryTask" useGeneratedKeys="true" keyProperty="id"> <insert id="insertInventoryTask" parameterType="InventoryTask" useGeneratedKeys="true" keyProperty="id">
insert into inventory_task insert into inventory_task
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

View File

@@ -325,62 +325,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
--> -->
<select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map"> <select id="selectGroupedByBill" resultMap="RkInfoResult" parameterType="map">
SELECT SELECT
/* ============= 主键:取单据内任一(用最小 ID 代表) ============= */ a.id,
MIN(t.id) AS id, a.bill_no,
a.bill_no_ck,
/* ============= 单据号 ============= */ a.rk_type,
t.bill_no AS bill_no, -- 入库单据号(分组键) si.type_name AS rk_type_name,
ANY_VALUE(t.bill_no_ck) AS bill_no_ck, -- 出库单据号(若单据发生过出库则可能有值) a.wl_type,
a.cangku,
/* ============= 通用字段(代表值/聚合) ============= */ a.rk_time,
ANY_VALUE(t.rk_type) AS rk_type, -- 入库类型编码type_code a.lihuo_y,
-- 入库类型名称(由 stock_in_type 反查) a.is_chuku,
(SELECT si.type_name a.xj,
FROM stock_in_type si a.xm_no,
WHERE si.type_code = ANY_VALUE(t.rk_type) a.xm_ms,
LIMIT 1) AS rk_type_name, a.xm_no_ck,
a.xm_ms_ck,
ANY_VALUE(t.wl_type) AS wl_type, -- 物资类型 a.wl_no,
ANY_VALUE(t.cangku) AS cangku, -- 仓库(编码) a.wl_ms,
MIN(t.rk_time) AS rk_time, -- 入库时间(单据内最早) a.gys_no,
ANY_VALUE(t.lihuo_y) AS lihuo_y, -- 理货员ID a.sap_no,
MAX(t.is_chuku) AS is_chuku, -- 是否出库(单据内只要有出库,用最大值反映) a.ck_type,
ANY_VALUE(t.xj) AS xj, -- 县局 so.type_name AS ck_type_name,
a.ly_time,
ANY_VALUE(t.xm_no) AS xm_no, -- 入库项目号 a.ck_lihuo_y,
ANY_VALUE(t.xm_ms) AS xm_ms, -- 入库项目描述 u.user_name AS ck_lihuo_y_name
ANY_VALUE(t.xm_no_ck) AS xm_no_ck, -- 出库项目号
ANY_VALUE(t.xm_ms_ck) AS xm_ms_ck, -- 出库项目描述
ANY_VALUE(t.wl_no) AS wl_no, -- 物料号
ANY_VALUE(t.wl_ms) AS wl_ms, -- 物料描述
ANY_VALUE(t.gys_no) AS gys_no, -- 供应商编码
ANY_VALUE(t.sap_no) AS sap_no, -- SAP 订单号
/* ============= 出库附加信息 ============= */
ANY_VALUE(t.ck_type) AS ck_type, -- 出库类型编码
(SELECT s.type_name
FROM stock_out_type s
WHERE s.type_code = ANY_VALUE(t.ck_type)
LIMIT 1) AS ck_type_name, -- 出库类型名称
MAX(t.ly_time) AS ly_time, -- 领用时间(单据内最新)
ANY_VALUE(t.ck_lihuo_y) AS ck_lihuo_y, -- 出库理货员ID
(SELECT u.user_name
FROM sys_user u
WHERE u.user_id = ANY_VALUE(t.ck_lihuo_y)
LIMIT 1) AS ck_lihuo_y_name -- 出库理货员姓名
FROM ( FROM (
<!-- 这里完全复用你已有的 SELECT + JOIN 片段,列别名与 RkInfoResult 一致 --> SELECT
MIN(t.id) AS id, -- 代表ID
t.bill_no AS bill_no, -- 分组键
MIN(t.bill_no_ck) AS bill_no_ck, -- 代表值
MIN(t.rk_type) AS rk_type,
MIN(t.wl_type) AS wl_type,
MIN(t.cangku) AS cangku,
MIN(t.rk_time) AS rk_time, -- 单据内最早入库时间
MIN(t.lihuo_y) AS lihuo_y,
MAX(t.is_chuku) AS is_chuku, -- 单据内只要有出库则为1
MIN(t.xj) AS xj,
MIN(t.xm_no) AS xm_no,
MIN(t.xm_ms) AS xm_ms,
MIN(t.xm_no_ck) AS xm_no_ck,
MIN(t.xm_ms_ck) AS xm_ms_ck,
MIN(t.wl_no) AS wl_no,
MIN(t.wl_ms) AS wl_ms,
MIN(t.gys_no) AS gys_no,
MIN(t.sap_no) AS sap_no,
MIN(t.ck_type) AS ck_type,
MAX(t.ly_time) AS ly_time,
MIN(t.ck_lihuo_y) AS ck_lihuo_y
FROM (
<!-- 复用已有的明细查询(列别名与 RkInfoResult 一致) -->
<include refid="selectRkInfoVo"/> <include refid="selectRkInfoVo"/>
) t ) t
<where> <where>
<!-- ================= 与 /list 相同的筛选条件(把 ri.* 改为 t.* ================= --> <!-- is_chuku 优先列表,其次单值 -->
<!-- is_chuku优先列表其次单值 -->
<choose> <choose>
<when test="q.isChukuList != null and q.isChukuList.size > 0"> <when test="q.isChukuList != null and q.isChukuList.size > 0">
AND t.is_chuku IN AND t.is_chuku IN
@@ -396,29 +393,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 关键词模糊 --> <!-- 关键词模糊 -->
<if test="q.keyword != null and q.keyword != ''"> <if test="q.keyword != null and q.keyword != ''">
AND ( AND (
t.xm_no like concat('%', #{q.keyword}, '%') t.xm_no LIKE concat('%', #{q.keyword}, '%')
or t.xm_ms like concat('%', #{q.keyword}, '%') OR t.xm_ms LIKE concat('%', #{q.keyword}, '%')
or t.wl_no like concat('%', #{q.keyword}, '%') OR t.wl_no LIKE concat('%', #{q.keyword}, '%')
or t.wl_ms like concat('%', #{q.keyword}, '%') OR t.wl_ms LIKE concat('%', #{q.keyword}, '%')
or t.gys_no like concat('%', #{q.keyword}, '%') OR t.gys_no LIKE concat('%', #{q.keyword}, '%')
or t.gys_mc like concat('%', #{q.keyword}, '%') OR t.gys_mc LIKE concat('%', #{q.keyword}, '%')
or t.sap_no like concat('%', #{q.keyword}, '%') OR t.sap_no LIKE concat('%', #{q.keyword}, '%')
or t.bill_no like concat('%', #{q.keyword}, '%') OR t.bill_no LIKE concat('%', #{q.keyword}, '%')
or t.bill_no_ck like concat('%', #{q.keyword}, '%') OR t.bill_no_ck LIKE concat('%', #{q.keyword}, '%')
or t.ck_type like concat('%', #{q.keyword}, '%') OR t.ck_type LIKE concat('%', #{q.keyword}, '%')
or t.pcode like concat('%', #{q.keyword}, '%') OR t.pcode LIKE concat('%', #{q.keyword}, '%')
) )
</if> </if>
<!-- 维度筛选 --> <!-- 维度筛选 -->
<if test="q.rkType != null and q.rkType != ''"> <if test="q.rkType != null and q.rkType != ''">
AND t.rk_type like concat('%', #{q.rkType}, '%') AND t.rk_type LIKE concat('%', #{q.rkType}, '%')
</if> </if>
<if test="q.wlType != null and q.wlType != ''"> <if test="q.wlType != null and q.wlType != ''">
AND t.wl_type like concat('%', #{q.wlType}, '%') AND t.wl_type LIKE concat('%', #{q.wlType}, '%')
</if> </if>
<if test="q.cangku != null and q.cangku != ''"> <if test="q.cangku != null and q.cangku != ''">
AND t.cangku like concat('%', #{q.cangku}, '%') AND t.cangku LIKE concat('%', #{q.cangku}, '%')
</if> </if>
<!-- ID 列表 --> <!-- ID 列表 -->
@@ -447,88 +444,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 其它模糊/等值 --> <!-- 其它模糊/等值 -->
<if test="q.lihuoY != null and q.lihuoY != ''"> <if test="q.lihuoY != null and q.lihuoY != ''">
AND t.lihuo_y like concat('%', #{q.lihuoY}, '%') AND t.lihuo_y LIKE concat('%', #{q.lihuoY}, '%')
</if> </if>
<if test="q.xj != null and q.xj != ''"> <if test="q.xj != null and q.xj != ''">
AND t.xj like concat('%', #{q.xj}, '%') AND t.xj LIKE concat('%', #{q.xj}, '%')
</if> </if>
<if test="q.billNo != null and q.billNo != ''"> <if test="q.billNo != null and q.billNo != ''">
AND t.bill_no like concat('%', #{q.billNo}, '%') AND t.bill_no LIKE concat('%', #{q.billNo}, '%')
</if> </if>
<if test="q.billNoCk != null and q.billNoCk != ''"> <if test="q.billNoCk != null and q.billNoCk != ''">
AND t.bill_no_ck like concat('%', #{q.billNoCk}, '%') AND t.bill_no_ck LIKE concat('%', #{q.billNoCk}, '%')
</if> </if>
<if test="q.xmNo != null and q.xmNo != ''"> <if test="q.xmNo != null and q.xmNo != ''">
AND t.xm_no like concat('%', #{q.xmNo}, '%') AND t.xm_no LIKE concat('%', #{q.xmNo}, '%')
</if> </if>
<if test="q.xmMs != null and q.xmMs != ''"> <if test="q.xmMs != null and q.xmMs != ''">
AND t.xm_ms like concat('%', #{q.xmMs}, '%') AND t.xm_ms LIKE concat('%', #{q.xmMs}, '%')
</if> </if>
<if test="q.wlNo != null and q.wlNo != ''"> <if test="q.wlNo != null and q.wlNo != ''">
AND t.wl_no like concat('%', #{q.wlNo}, '%') AND t.wl_no LIKE concat('%', #{q.wlNo}, '%')
</if> </if>
<if test="q.wlMs != null and q.wlMs != ''"> <if test="q.wlMs != null and q.wlMs != ''">
AND t.wl_ms like concat('%', #{q.wlMs}, '%') AND t.wl_ms LIKE concat('%', #{q.wlMs}, '%')
</if> </if>
<if test="q.gysNo != null and q.gysNo != ''"> <if test="q.gysNo != null and q.gysNo != ''">
AND t.gys_no like concat('%', #{q.gysNo}, '%') AND t.gys_no LIKE concat('%', #{q.gysNo}, '%')
</if> </if>
<if test="q.gysMc != null and q.gysMc != ''"> <if test="q.gysMc != null and q.gysMc != ''">
AND t.gys_mc like concat('%', #{q.gysMc}, '%') AND t.gys_mc LIKE concat('%', #{q.gysMc}, '%')
</if> </if>
<if test="q.jhAmt != null"> <if test="q.jhAmt != null"> AND t.jh_amt = #{q.jhAmt} </if>
AND t.jh_amt = #{q.jhAmt} <if test="q.htDj != null"> AND t.ht_dj = #{q.htDj} </if>
</if>
<if test="q.htDj != null">
AND t.ht_dj = #{q.htDj}
</if>
<if test="q.sapNo != null and q.sapNo != ''"> <if test="q.sapNo != null and q.sapNo != ''">
AND t.sap_no like concat('%', #{q.sapNo}, '%') AND t.sap_no LIKE concat('%', #{q.sapNo}, '%')
</if> </if>
<if test="q.xh != null and q.xh != ''"> <if test="q.xh != null and q.xh != ''">
AND t.xh like concat('%', #{q.xh}, '%') AND t.xh LIKE concat('%', #{q.xh}, '%')
</if>
<if test="q.jhQty != null">
AND t.jh_qty = #{q.jhQty}
</if>
<if test="q.htQty != null">
AND t.ht_qty = #{q.htQty}
</if> </if>
<if test="q.jhQty != null"> AND t.jh_qty = #{q.jhQty} </if>
<if test="q.htQty != null"> AND t.ht_qty = #{q.htQty} </if>
<if test="q.dw != null and q.dw != ''"> <if test="q.dw != null and q.dw != ''">
AND t.dw like concat('%', #{q.dw}, '%') AND t.dw LIKE concat('%', #{q.dw}, '%')
</if>
<if test="q.realQty != null">
AND t.real_qty = #{q.realQty}
</if> </if>
<if test="q.realQty != null"> AND t.real_qty = #{q.realQty} </if>
<if test="q.pcode != null and q.pcode != ''"> <if test="q.pcode != null and q.pcode != ''">
AND t.pcode like concat('%', #{q.pcode}, '%') AND t.pcode LIKE concat('%', #{q.pcode}, '%')
</if>
<if test="q.lyTime != null">
AND t.ly_time = #{q.lyTime}
</if>
<if test="q.returnTime != null">
AND t.return_time = #{q.returnTime}
</if> </if>
<if test="q.lyTime != null"> AND t.ly_time = #{q.lyTime} </if>
<if test="q.returnTime != null"> AND t.return_time = #{q.returnTime} </if>
<if test="q.trayCode != null and q.trayCode != ''"> <if test="q.trayCode != null and q.trayCode != ''">
AND t.tray_code like concat('%', #{q.trayCode}, '%') AND t.tray_code LIKE concat('%', #{q.trayCode}, '%')
</if> </if>
<if test="q.entityId != null and q.entityId != ''"> <if test="q.entityId != null and q.entityId != ''">
AND t.entity_id like concat('%', #{q.entityId}, '%') AND t.entity_id LIKE concat('%', #{q.entityId}, '%')
</if> </if>
<if test="q.ckType != null and q.ckType != ''"> <if test="q.ckType != null and q.ckType != ''">
AND t.ck_type like concat('%', #{q.ckType}, '%') AND t.ck_type LIKE concat('%', #{q.ckType}, '%')
</if> </if>
<!-- 若查询出库单据:单值 is_chuku=1 或 列表包含 1要求已生成出库单号 --> <!-- 若查询出库单据,则要求已生成出库单号 -->
<if test="(q.isChuku != null and q.isChuku == 1) <if test="(q.isChuku != null and q.isChuku == 1)
or (q.isChukuList != null and q.isChukuList.size > 0 and q.isChukuList.contains(1))"> or (q.isChukuList != null and q.isChukuList.size > 0 and q.isChukuList.contains(1))">
AND t.bill_no_ck IS NOT NULL AND t.bill_no_ck IS NOT NULL
</if> </if>
<!-- 删除标记(默认 0 --> <!-- 删除标记默认0 -->
<choose> <choose>
<when test="q.isDelete != null and q.isDelete != ''"> <when test="q.isDelete != null and q.isDelete != ''">
AND t.is_delete = #{q.isDelete} AND t.is_delete = #{q.isDelete}
@@ -538,7 +521,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise> </otherwise>
</choose> </choose>
<!-- 审核开启:剔除审核失败”的明细(未审核/通过保留 --> <!-- 审核开启:剔除审核失败(不使用 &lt;&gt;,而用 != 或 CDATA -->
<if test="needAudit != null and needAudit == 1"> <if test="needAudit != null and needAudit == 1">
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 SELECT 1
@@ -549,13 +532,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) )
</if> </if>
</where> </where>
GROUP BY t.bill_no GROUP BY t.bill_no
ORDER BY MIN(t.rk_time) DESC ) a
LEFT JOIN stock_in_type si ON a.rk_type = si.type_code
LEFT JOIN stock_out_type so ON a.ck_type = so.type_code
LEFT JOIN sys_user u ON a.ck_lihuo_y = u.user_id
ORDER BY a.rk_time DESC
</select> </select>
<select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult"> <select id="selectRkInfoById" parameterType="Long" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/> <include refid="selectRkInfoVo"/>
where ri.id = #{id} and ri.is_delete = 0 where ri.id = #{id} and ri.is_delete = 0
@@ -600,7 +585,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE bill_no = #{billNo} AND sap_no IS NOT NULL WHERE bill_no = #{billNo} AND sap_no IS NOT NULL
</select> </select>
<select id="getByPcodeIdList" parameterType="list" resultMap="RkInfoResult"> <!-- 正常数据:扫描到的库位(限定场景) -->
<select id="getByPcodeIdList" parameterType="map" resultMap="RkInfoResult">
SELECT SELECT
ri.id, ri.rk_type, ri.wl_type, ri.cangku, ri.rk_time, ri.lihuo_y, ri.id, ri.rk_type, ri.wl_type, ri.cangku, ri.rk_time, ri.lihuo_y,
ri.is_chuku, ri.bill_no, ri.bill_no_ck, ri.is_chuku, ri.bill_no, ri.bill_no_ck,
@@ -611,40 +597,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ri.ck_lihuo_y, ri.ck_type, ri.team_code, ri.ly_time, ri.ck_remark, ri.ck_lihuo_y, ri.ck_type, ri.team_code, ri.ly_time, ri.ck_remark,
ri.create_by, ri.create_time, ri.update_by, ri.update_time, ri.is_delete ri.create_by, ri.create_time, ri.update_by, ri.update_time, ri.is_delete
FROM rk_info ri FROM rk_info ri
JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
WHERE ri.is_delete = '0' WHERE ri.is_delete = '0'
AND pd.is_delete = '0'
AND ri.is_chuku = '0'
AND pd.scene = #{sceneId}
AND ri.pcode_id IN AND ri.pcode_id IN
<foreach collection="list" item="id" open="(" separator="," close=")"> <foreach collection="list" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</select> </select>
<select id="getMissedPcodeIds" parameterType="list" resultMap="RkInfoResult"> <!-- 未扫描到的数据(限定场景) -->
<select id="getMissedPcodeIds" parameterType="map" resultMap="RkInfoResult">
SELECT SELECT
id, rk_type, wl_type, cangku, rk_time, lihuo_y, ri.id, ri.rk_type, ri.wl_type, ri.cangku, ri.rk_time, ri.lihuo_y,
is_chuku, bill_no, bill_no_ck, ri.is_chuku, ri.bill_no, ri.bill_no_ck,
remark, xj, xm_no, xm_ms, wl_no, wl_ms, is_borrowed, ri.remark, ri.xj, ri.xm_no, ri.xm_ms, ri.wl_no, ri.wl_ms, ri.is_borrowed,
gys_no, gys_mc, jh_amt, ht_dj, sap_no, xh, ri.gys_no, ri.gys_mc, ri.jh_amt, ri.ht_dj, ri.sap_no, ri.xh,
jh_qty, ht_qty, dw, real_qty, ri.jh_qty, ri.ht_qty, ri.dw, ri.real_qty,
pcode, pcode_id, tray_code, entity_id, ri.pcode, ri.pcode_id, ri.tray_code, ri.entity_id,
ck_lihuo_y, ck_type, team_code, ly_time, ck_remark, ri.ck_lihuo_y, ri.ck_type, ri.team_code, ri.ly_time, ri.ck_remark,
create_by, create_time, update_by, update_time, is_delete ri.create_by, ri.create_time, ri.update_by, ri.update_time, ri.is_delete
FROM rk_info FROM rk_info ri
WHERE is_delete = '0' JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
WHERE ri.is_delete = '0'
AND ri.is_chuku = '0'
AND pd.is_delete = '0'
AND pd.scene = #{sceneId}
<if test="list != null and list.size() > 0"> <if test="list != null and list.size() > 0">
AND pcode_id NOT IN AND ri.pcode_id NOT IN
<foreach collection="list" item="id" open="(" separator="," close=")"> <foreach collection="list" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="existsByPcodeId" parameterType="string" resultType="java.lang.Integer"> <!-- 判断某个库位在场景内是否存在 -->
<select id="existsByPcodeId" parameterType="map" resultType="java.lang.Integer">
SELECT COUNT(1) SELECT COUNT(1)
FROM rk_info FROM rk_info ri
WHERE is_delete = '0' JOIN pcde_detail pd ON ri.pcode_id = pd.encoded_id
AND pcode_id = #{pcodeId} WHERE ri.is_delete = '0'
AND pd.is_delete = '0'
AND ri.is_chuku = '0'
AND ri.pcode_id = #{pcodeId}
AND pd.scene = #{sceneId}
</select> </select>
<select id="countGetByWh" resultType="java.lang.Integer" parameterType="java.lang.String"> <select id="countGetByWh" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(1) FROM rk_info SELECT COUNT(1) FROM rk_info
WHERE is_delete = '0' WHERE is_delete = '0'
@@ -871,5 +872,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bill_no IS NOT NULL AND bill_no IS NOT NULL
</update> </update>
<select id="listRkInfoByPcode"
parameterType="string"
resultMap="RkInfoResult">
SELECT
t.*,
wh.warehouse_name AS cangku_name
FROM rk_info t
LEFT JOIN warehouse_info wh
ON wh.warehouse_code = t.cangku
WHERE t.is_delete = 0
AND t.is_chuku = 0
AND t.pcode = #{pcode}
ORDER BY t.rk_time DESC, t.id DESC
</select>
</mapper> </mapper>