新增库存列表接口,根据订单编号排序
追加入库接口逻辑修改
This commit is contained in:
@@ -68,6 +68,14 @@ public interface PcdeDetailMapper
|
|||||||
*/
|
*/
|
||||||
PcdeDetail selectByPcode(String pcode);
|
PcdeDetail selectByPcode(String pcode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据仓库编码和库位编码查询库位信息
|
||||||
|
* @param pcode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PcdeDetail selectByPcodeAndWarehouse(@Param("pcode") String pcode,
|
||||||
|
@Param("warehouseCode") String warehouseCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据仓库编码查询库位编码
|
* 根据仓库编码查询库位编码
|
||||||
* @param pcode
|
* @param pcode
|
||||||
|
|||||||
@@ -48,6 +48,18 @@ public class RkInfoController extends BaseController
|
|||||||
return getDataTable(list);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出库存单据明细列表
|
* 导出库存单据明细列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -155,4 +155,9 @@ public interface RkInfoMapper
|
|||||||
int countGetByWh(@org.apache.ibatis.annotations.Param("warehouse") String warehouse);
|
int countGetByWh(@org.apache.ibatis.annotations.Param("warehouse") String warehouse);
|
||||||
|
|
||||||
List<RkInfo> listRkInfoByPcode(String pcode);
|
List<RkInfo> listRkInfoByPcode(String pcode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询库存单据明细列表(按单据号排序)
|
||||||
|
*/
|
||||||
|
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,4 +96,9 @@ public interface IRkInfoService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<RkInfo> listRkInfoByPcode(String pcode);
|
List<RkInfo> listRkInfoByPcode(String pcode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询库存单据明细列表(按单据号排序)
|
||||||
|
*/
|
||||||
|
List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,10 @@ public class RkBillServiceImpl implements IRkBillService
|
|||||||
|
|
||||||
// 库位校验
|
// 库位校验
|
||||||
if (StringUtils.isNotBlank(info.getPcode())) {
|
if (StringUtils.isNotBlank(info.getPcode())) {
|
||||||
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
|
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
|
||||||
|
info.getPcode(),
|
||||||
|
bill.getCangku()
|
||||||
|
);
|
||||||
if (pcde == null) {
|
if (pcde == null) {
|
||||||
throw new RuntimeException("库位不存在:" + info.getPcode());
|
throw new RuntimeException("库位不存在:" + info.getPcode());
|
||||||
}
|
}
|
||||||
@@ -331,38 +334,53 @@ public class RkBillServiceImpl implements IRkBillService
|
|||||||
throw new ServiceException("单据不存在:" + billNo);
|
throw new ServiceException("单据不存在:" + billNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================== 2️⃣ 执行状态规则 ================== */
|
/* ================== 2️⃣ 取前端选择仓库 ================== */
|
||||||
|
String frontCangku = dto.getRkBill().getCangku();
|
||||||
|
if (StringUtils.isBlank(frontCangku)) {
|
||||||
|
frontCangku = bill.getCangku();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================== 3️⃣ 执行状态 ================== */
|
||||||
String execStatus = dto.getRkBill().getExecStatus();
|
String execStatus = dto.getRkBill().getExecStatus();
|
||||||
if (StringUtils.isBlank(execStatus)) {
|
if (StringUtils.isBlank(execStatus)) {
|
||||||
execStatus = bill.getExecStatus();
|
execStatus = bill.getExecStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 标记:本次是否包含预入库
|
|
||||||
boolean hasPreIn = false;
|
boolean hasPreIn = false;
|
||||||
|
|
||||||
List<RkInfo> rkInfoList = dto.getRkInfoList();
|
List<RkInfo> rkInfoList = dto.getRkInfoList();
|
||||||
|
|
||||||
/* ================== 3️⃣ 追加前:供应计划【批量】校验 ================== */
|
/* ================== 4️⃣ 供应计划校验 ================== */
|
||||||
checkGysJhQtyBeforeInStockBatch(rkInfoList);
|
checkGysJhQtyBeforeInStockBatch(rkInfoList);
|
||||||
|
|
||||||
/* ================== 4️⃣ 插入明细 & 事件 ================== */
|
/* ================== 5️⃣ 追加明细 ================== */
|
||||||
for (RkInfo info : rkInfoList) {
|
for (RkInfo info : rkInfoList) {
|
||||||
|
|
||||||
/* 4.1 库位校验 */
|
/* 5.1 库位校验 → 用【前端仓库】 */
|
||||||
if (StringUtils.isNotBlank(info.getPcode())) {
|
if (StringUtils.isNotBlank(info.getPcode())) {
|
||||||
PcdeDetail pcde = pcdeDetailMapper.selectByPcode(info.getPcode());
|
|
||||||
|
PcdeDetail pcde = pcdeDetailMapper.selectByPcodeAndWarehouse(
|
||||||
|
info.getPcode(),
|
||||||
|
frontCangku
|
||||||
|
);
|
||||||
|
|
||||||
if (pcde == null) {
|
if (pcde == null) {
|
||||||
throw new ServiceException("库位不存在:" + info.getPcode());
|
throw new ServiceException(
|
||||||
|
"库位不存在或不属于当前仓库:"
|
||||||
|
+ info.getPcode()
|
||||||
|
+ ",仓库:" + frontCangku
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.setPcodeId(pcde.getEncodedId());
|
info.setPcodeId(pcde.getEncodedId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4.2 继承主单字段 */
|
/* 5.2 继承主单字段 */
|
||||||
info.setBillNo(bill.getBillNo());
|
info.setBillNo(bill.getBillNo());
|
||||||
info.setOperationType(bill.getOperationType());
|
info.setOperationType(bill.getOperationType());
|
||||||
info.setBizType(bill.getBizType());
|
info.setBizType(bill.getBizType());
|
||||||
info.setWlType(bill.getWlType());
|
info.setWlType(bill.getWlType());
|
||||||
info.setCangku(bill.getCangku());
|
|
||||||
|
info.setCangku(frontCangku);
|
||||||
|
|
||||||
info.setOperationTime(now);
|
info.setOperationTime(now);
|
||||||
info.setOperator(bill.getOperator());
|
info.setOperator(bill.getOperator());
|
||||||
@@ -376,36 +394,36 @@ public class RkBillServiceImpl implements IRkBillService
|
|||||||
info.setHasMoved("0");
|
info.setHasMoved("0");
|
||||||
info.setIsBorrowed("0");
|
info.setIsBorrowed("0");
|
||||||
|
|
||||||
/* 4.3 备注兜底 */
|
|
||||||
String finalRemark = StringUtils.isNotBlank(info.getRemark())
|
String finalRemark = StringUtils.isNotBlank(info.getRemark())
|
||||||
? info.getRemark()
|
? info.getRemark()
|
||||||
: bill.getRemark();
|
: bill.getRemark();
|
||||||
info.setRemark(finalRemark);
|
info.setRemark(finalRemark);
|
||||||
|
|
||||||
/* 4.4 审计字段 */
|
|
||||||
info.setCreateTime(now);
|
info.setCreateTime(now);
|
||||||
info.setCreateBy(bill.getCreateBy());
|
info.setCreateBy(bill.getCreateBy());
|
||||||
info.setIsDelete("0");
|
info.setIsDelete("0");
|
||||||
|
|
||||||
/* 4.5 插入 rk_info */
|
/* 5.3 插入 rk_info */
|
||||||
rkInfoMapper.insertRkInfo(info);
|
rkInfoMapper.insertRkInfo(info);
|
||||||
|
|
||||||
/* 4.6 插入 rk_record */
|
/* 5.4 插入 rk_record */
|
||||||
RkRecord record = buildInRkRecord(bill, info, now);
|
RkRecord record = buildInRkRecord(bill, info, now);
|
||||||
record.setExecStatus(execStatus);
|
record.setExecStatus(execStatus);
|
||||||
record.setRkInfoId(info.getId());
|
record.setRkInfoId(info.getId());
|
||||||
record.setPcodeId(info.getPcodeId());
|
record.setPcodeId(info.getPcodeId());
|
||||||
record.setRemark(finalRemark);
|
record.setRemark(finalRemark);
|
||||||
|
|
||||||
|
record.setCangku(frontCangku);
|
||||||
|
|
||||||
rkRecordMapper.insertRkRecord(record);
|
rkRecordMapper.insertRkRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================== 5️⃣ 追加后:供应计划【仅完成入库】 ================== */
|
/* ================== 6️⃣ 供应计划回写 ================== */
|
||||||
if ("1".equals(execStatus)) {
|
if ("1".equals(execStatus)) {
|
||||||
handleGysJhAfterInStockBatch(rkInfoList);
|
handleGysJhAfterInStockBatch(rkInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================== 6️⃣ 同步回退主单状态 ================== */
|
/* ================== 7️⃣ 主单状态回退 ================== */
|
||||||
if (hasPreIn && !"0".equals(bill.getExecStatus())) {
|
if (hasPreIn && !"0".equals(bill.getExecStatus())) {
|
||||||
rkBillMapper.updateExecStatusByBillNo(billNo, "0");
|
rkBillMapper.updateExecStatusByBillNo(billNo, "0");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,4 +270,10 @@ public class RkInfoServiceImpl implements IRkInfoService
|
|||||||
public List<RkInfo> listRkInfoByPcode(String pcode) {
|
public List<RkInfo> listRkInfoByPcode(String pcode) {
|
||||||
return rkInfoMapper.listRkInfoByPcode(pcode);
|
return rkInfoMapper.listRkInfoByPcode(pcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RkInfo> selectRkInfoListOrderByBillNo(RkInfo rkInfo)
|
||||||
|
{
|
||||||
|
return rkInfoMapper.selectRkInfoListOrderByBillNo(rkInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,33 @@
|
|||||||
AND is_delete = '0'
|
AND is_delete = '0'
|
||||||
</select>
|
</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 -->
|
<!-- 根据库位编码查编码后ID -->
|
||||||
<select id="selectEncodedIdByPcode"
|
<select id="selectEncodedIdByPcode"
|
||||||
resultType="java.lang.String"
|
resultType="java.lang.String"
|
||||||
|
|||||||
@@ -104,7 +104,6 @@
|
|||||||
<select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult">
|
<select id="selectRkBillList" parameterType="RkBill" resultMap="RkBillResult">
|
||||||
<include refid="selectRkBillVo"/>
|
<include refid="selectRkBillVo"/>
|
||||||
<where>
|
<where>
|
||||||
AND rb.is_delivery ='1'
|
|
||||||
<if test="wlType != null and wlType != ''">
|
<if test="wlType != null and wlType != ''">
|
||||||
AND rb.wl_type = #{wlType}
|
AND rb.wl_type = #{wlType}
|
||||||
</if>
|
</if>
|
||||||
@@ -121,7 +120,7 @@
|
|||||||
AND rb.operation_type = #{operationType}
|
AND rb.operation_type = #{operationType}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="bizTypeList != null and bizTypeList.size > 0">
|
<if test="bizTypeList != null and bizTypeList.size() > 0">
|
||||||
AND rb.biz_type IN
|
AND rb.biz_type IN
|
||||||
<foreach collection="bizTypeList" item="bt" open="(" separator="," close=")">
|
<foreach collection="bizTypeList" item="bt" open="(" separator="," close=")">
|
||||||
#{bt}
|
#{bt}
|
||||||
|
|||||||
@@ -500,4 +500,75 @@
|
|||||||
ORDER BY t.operation_time DESC, t.id DESC
|
ORDER BY t.operation_time DESC, t.id DESC
|
||||||
</select>
|
</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 >= #{startDate}
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null">
|
||||||
|
AND ri.operation_time <= #{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>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user