新增库存列表接口,根据订单编号排序

追加入库接口逻辑修改
This commit is contained in:
2026-02-05 16:25:28 +08:00
parent 6ffafc81f4
commit 27a105b4f6
9 changed files with 170 additions and 19 deletions

View File

@@ -68,6 +68,14 @@ public interface PcdeDetailMapper
*/
PcdeDetail selectByPcode(String pcode);
/**
* 根据仓库编码和库位编码查询库位信息
* @param pcode
* @return
*/
PcdeDetail selectByPcodeAndWarehouse(@Param("pcode") String pcode,
@Param("warehouseCode") String warehouseCode);
/**
* 根据仓库编码查询库位编码
* @param pcode

View File

@@ -48,6 +48,18 @@ public class RkInfoController extends BaseController
return getDataTable(list);
}
/**
* 查询库存单据明细列表(按订单编号排序)
*/
@PreAuthorize("@ss.hasPermi('wisdom:stock:list')")
@GetMapping("/listByBillNo")
public TableDataInfo listByBillNo(RkInfo rkInfo)
{
startPage();
List<RkInfo> list = rkInfoService.selectRkInfoListOrderByBillNo(rkInfo);
return getDataTable(list);
}
/**
* 导出库存单据明细列表
*/

View File

@@ -155,4 +155,9 @@ public interface RkInfoMapper
int countGetByWh(@org.apache.ibatis.annotations.Param("warehouse") String warehouse);
List<RkInfo> listRkInfoByPcode(String pcode);
/**
* 查询库存单据明细列表(按单据号排序)
*/
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
}

View File

@@ -96,4 +96,9 @@ public interface IRkInfoService
* @return
*/
List<RkInfo> listRkInfoByPcode(String pcode);
/**
* 查询库存单据明细列表(按单据号排序)
*/
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
}

View File

@@ -136,7 +136,10 @@ public class RkBillServiceImpl implements IRkBillService
// 库位校验
if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
info.getPcode(),
bill.getCangku()
);
if (pcde == null) {
throw new RuntimeException("库位不存在:" + info.getPcode());
}
@@ -331,38 +334,53 @@ public class RkBillServiceImpl implements IRkBillService
throw new ServiceException("单据不存在:" + billNo);
}
/* ================== 2执行状态规则 ================== */
/* ================== 2取前端选择仓库 ================== */
String frontCangku = dto.getRkBill().getCangku();
if (StringUtils.isBlank(frontCangku)) {
frontCangku = bill.getCangku();
}
/* ================== 3⃣ 执行状态 ================== */
String execStatus = dto.getRkBill().getExecStatus();
if (StringUtils.isBlank(execStatus)) {
execStatus = bill.getExecStatus();
}
// 标记:本次是否包含预入库
boolean hasPreIn = false;
List<RkInfo> rkInfoList = dto.getRkInfoList();
/* ================== 3️⃣ 追加前:供应计划【批量】校验 ================== */
/* ================== 4️⃣ 供应计划校验 ================== */
checkGysJhQtyBeforeInStockBatch(rkInfoList);
/* ================== 4️⃣ 插入明细 & 事件 ================== */
/* ================== 5️⃣ 追加明细 ================== */
for (RkInfo info : rkInfoList) {
/* 4.1 库位校验 */
/* 5.1 库位校验 → 用【前端仓库】 */
if (StringUtils.isNotBlank(info.getPcode())) {
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
info.getPcode(),
frontCangku
);
if (pcde == null) {
throw new ServiceException("库位不存在:" + info.getPcode());
throw new ServiceException(
"库位不存在或不属于当前仓库:"
+ info.getPcode()
+ ",仓库:" + frontCangku
);
}
info.setPcodeId(pcde.getEncodedId());
}
/* 4.2 继承主单字段 */
/* 5.2 继承主单字段 */
info.setBillNo(bill.getBillNo());
info.setOperationType(bill.getOperationType());
info.setBizType(bill.getBizType());
info.setWlType(bill.getWlType());
info.setCangku(bill.getCangku());
info.setCangku(frontCangku);
info.setOperationTime(now);
info.setOperator(bill.getOperator());
@@ -376,36 +394,36 @@ public class RkBillServiceImpl implements IRkBillService
info.setHasMoved("0");
info.setIsBorrowed("0");
/* 4.3 备注兜底 */
String finalRemark = StringUtils.isNotBlank(info.getRemark())
? info.getRemark()
: bill.getRemark();
info.setRemark(finalRemark);
/* 4.4 审计字段 */
info.setCreateTime(now);
info.setCreateBy(bill.getCreateBy());
info.setIsDelete("0");
/* 4.5 插入 rk_info */
/* 5.3 插入 rk_info */
rkInfoMapper.insertRkInfo(info);
/* 4.6 插入 rk_record */
/* 5.4 插入 rk_record */
RkRecord record = buildInRkRecord(bill, info, now);
record.setExecStatus(execStatus);
record.setRkInfoId(info.getId());
record.setPcodeId(info.getPcodeId());
record.setRemark(finalRemark);
record.setCangku(frontCangku);
rkRecordMapper.insertRkRecord(record);
}
/* ================== 5️⃣ 追加后:供应计划【仅完成入库】 ================== */
/* ================== 6️⃣ 供应计划回写 ================== */
if ("1".equals(execStatus)) {
handleGysJhAfterInStockBatch(rkInfoList);
}
/* ================== 6️⃣ 同步回退主单状态 ================== */
/* ================== 7️⃣ 主单状态回退 ================== */
if (hasPreIn && !"0".equals(bill.getExecStatus())) {
rkBillMapper.updateExecStatusByBillNo(billNo, "0");
}

View File

@@ -270,4 +270,10 @@ public class RkInfoServiceImpl implements IRkInfoService
public List<RkInfo> listRkInfoByPcode(String pcode) {
return rkInfoMapper.listRkInfoByPcode(pcode);
}
@Override
public List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo)
{
return rkInfoMapper.selectRkInfoListOrderByBillNo(rkInfo);
}
}

View File

@@ -140,6 +140,33 @@
AND is_delete = '0'
</select>
<!-- 根据 pcode + 小仓编码 精准定位 -->
<select id="selectByPcodeAndWarehouse"
resultType="com.zg.project.information.domain.PcdeDetail">
SELECT
id,
pcode,
scene,
parent_warehouse_code AS parentWarehouseCode,
parent_warehouse_name AS parentWarehouseName,
warehouse_code AS warehouseCode,
warehouse_name AS warehouseName,
encoded_id AS encodedId,
tag,
is_delete AS isDelete,
created_by AS createdBy,
created_at AS createdAt,
updated_by AS updatedBy,
updated_at AS updatedAt,
remark
FROM pcde_detail
WHERE pcode = #{pcode}
AND warehouse_code = #{warehouseCode}
AND is_delete = '0'
LIMIT 1
</select>
<!-- 根据库位编码查编码后ID -->
<select id="selectEncodedIdByPcode"
resultType="java.lang.String"

View File

@@ -104,7 +104,6 @@
<select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult">
<include refid="selectRkBillVo"/>
<where>
AND rb.is_delivery ='1'
<if test="wlType != null and wlType != ''">
AND rb.wl_type = #{wlType}
</if>
@@ -121,7 +120,7 @@
AND rb.operation_type = #{operationType}
</if>
<if test="bizTypeList != null and bizTypeList.size > 0">
<if test="bizTypeList != null and bizTypeList.size() > 0">
AND rb.biz_type IN
<foreach collection="bizTypeList" item="bt" open="(" separator="," close=")">
#{bt}

View File

@@ -500,4 +500,75 @@
ORDER BY t.operation_time DESC, t.id DESC
</select>
<!-- ========================= 按单据号排序查询列表 ========================= -->
<select id="selectRkInfoListOrderByBillNo" parameterType="RkInfo" resultMap="RkInfoResult">
<include refid="selectRkInfoVo"/>
<where>
ri.exec_status = 1
AND ri.is_chuku = 0
AND ri.is_delete = 0
<if test="operationType != null and operationType != ''">
AND ri.operation_type LIKE CONCAT('%', #{operationType}, '%')
</if>
<if test="sapNo != null and sapNo != ''">
AND ri.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<if test="xmNo != null and xmNo != ''">
AND ri.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<if test="xmMs != null and xmMs != ''">
AND ri.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<if test="wlNo != null and wlNo != ''">
AND ri.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<if test="wlMs != null and wlMs != ''">
AND ri.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<if test="gysMc != null and gysMc != ''">
AND ri.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<if test="pcode != null and pcode != ''">
AND ri.pcode LIKE CONCAT('%', #{pcode}, '%')
</if>
<if test="bizType != null and bizType != ''">
AND ri.biz_type LIKE CONCAT('%', #{bizType}, '%')
</if>
<if test="wlType != null and wlType != ''">
AND ri.wl_type LIKE CONCAT('%', #{wlType}, '%')
</if>
<if test="cangku != null and cangku != ''">
AND ri.cangku LIKE CONCAT('%', #{cangku}, '%')
</if>
<if test="billNo != null and billNo != ''">
AND ri.bill_no LIKE CONCAT('%', #{billNo}, '%')
</if>
<if test="isDelete != null and isDelete != ''">
AND ri.is_delete = #{isDelete}
</if>
<!-- 出入库时间范围 -->
<if test="startDate != null">
AND ri.operation_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND ri.operation_time &lt;= #{endDate}
</if>
</where>
ORDER BY
/* 1. 纯数字优先 */
(ri.sap_no REGEXP '^[0-9]+$') DESC,
/* 2. 纯数字按【从小到大】 */
CASE
WHEN ri.sap_no REGEXP '^[0-9]+$'
THEN CAST(ri.sap_no AS UNSIGNED)
ELSE 999999999999
END ASC,
/* 3. 字母混合按字符串 */
ri.sap_no ASC
</select>
</mapper>