2025-05-27 14:38:00 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
<!DOCTYPE mapper
|
2026-01-22 19:59:49 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-05-30 16:13:27 +08:00
|
|
|
<mapper namespace="com.zg.project.wisdom.mapper.GysJhMapper">
|
2026-01-22 19:59:49 +08:00
|
|
|
|
2025-05-27 14:38:00 +08:00
|
|
|
<resultMap type="GysJh" id="GysJhResult">
|
2026-01-22 19:59:49 +08:00
|
|
|
<result property="id" column="id"/>
|
|
|
|
|
<result property="indexNo" column="index_no"/>
|
|
|
|
|
<result property="xj" column="xj"/>
|
|
|
|
|
<result property="xmNo" column="xm_no"/>
|
|
|
|
|
<result property="xmMs" column="xm_ms"/>
|
|
|
|
|
<result property="wlNo" column="wl_no"/>
|
|
|
|
|
<result property="wlMs" column="wl_ms"/>
|
|
|
|
|
<result property="gysNo" column="gys_no"/>
|
|
|
|
|
<result property="gysMc" column="gys_mc"/>
|
|
|
|
|
<result property="jhAmt" column="jh_amt"/>
|
|
|
|
|
<result property="htDj" column="ht_dj"/>
|
|
|
|
|
<result property="sapNo" column="sap_no"/>
|
|
|
|
|
<result property="xh" column="xh"/>
|
|
|
|
|
<result property="jhQty" column="jh_qty"/>
|
|
|
|
|
<!-- 新增:已入库数量 -->
|
|
|
|
|
<result property="realQty" column="real_qty"/>
|
|
|
|
|
<result property="htQty" column="ht_qty"/>
|
|
|
|
|
<result property="dw" column="dw"/>
|
|
|
|
|
<result property="status" column="status"/>
|
|
|
|
|
<result property="entityId" column="entity_id"/>
|
|
|
|
|
<result property="remark" column="remark"/>
|
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
|
|
|
|
<result property="updateBy" column="update_by"/>
|
|
|
|
|
<result property="updateTime" column="update_time"/>
|
|
|
|
|
<result property="isDelete" column="is_delete"/>
|
2025-05-27 14:38:00 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectGysJhVo">
|
2026-01-22 19:59:49 +08:00
|
|
|
select
|
|
|
|
|
id,
|
|
|
|
|
index_no,
|
|
|
|
|
xj,
|
|
|
|
|
xm_no,
|
|
|
|
|
xm_ms,
|
|
|
|
|
wl_no,
|
|
|
|
|
wl_ms,
|
|
|
|
|
gys_no,
|
|
|
|
|
gys_mc,
|
|
|
|
|
jh_amt,
|
|
|
|
|
ht_dj,
|
|
|
|
|
sap_no,
|
|
|
|
|
xh,
|
|
|
|
|
jh_qty,
|
|
|
|
|
real_qty,
|
|
|
|
|
ht_qty,
|
|
|
|
|
dw,
|
|
|
|
|
status,
|
|
|
|
|
entity_id,
|
|
|
|
|
remark,
|
|
|
|
|
create_by,
|
|
|
|
|
create_time,
|
|
|
|
|
update_by,
|
|
|
|
|
update_time,
|
|
|
|
|
is_delete
|
|
|
|
|
from gys_jh
|
2025-05-27 14:38:00 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectGysJhList" parameterType="GysJh" resultMap="GysJhResult">
|
|
|
|
|
<include refid="selectGysJhVo"/>
|
2025-08-01 09:27:07 +08:00
|
|
|
<where>
|
|
|
|
|
<if test="xmNo != null and xmNo != ''">
|
|
|
|
|
and xm_no like concat('%', #{xmNo}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="xmMs != null and xmMs != ''">
|
|
|
|
|
and xm_ms like concat('%', #{xmMs}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="wlNo != null and wlNo != ''">
|
|
|
|
|
and wl_no like concat('%', #{wlNo}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="wlMs != null and wlMs != ''">
|
|
|
|
|
and wl_ms like concat('%', #{wlMs}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="gysMc != null and gysMc != ''">
|
|
|
|
|
and gys_mc like concat('%', #{gysMc}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="sapNo != null and sapNo != ''">
|
|
|
|
|
and sap_no like concat('%', #{sapNo}, '%')
|
|
|
|
|
</if>
|
2025-12-09 15:54:39 +08:00
|
|
|
<if test="status != null and status != ''">
|
|
|
|
|
and status = #{status}
|
|
|
|
|
</if>
|
2025-08-01 09:27:07 +08:00
|
|
|
<if test="isDelete != null and isDelete != ''">
|
|
|
|
|
and is_delete = #{isDelete}
|
|
|
|
|
</if>
|
2026-01-06 14:19:58 +08:00
|
|
|
<if test="beginTime != null">
|
|
|
|
|
and create_time <![CDATA[>=]]> #{beginTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime != null">
|
|
|
|
|
and create_time <![CDATA[<]]> #{endTime}
|
|
|
|
|
</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
2026-01-22 19:59:49 +08:00
|
|
|
|
2025-05-27 14:38:00 +08:00
|
|
|
<select id="selectGysJhById" parameterType="Long" resultMap="GysJhResult">
|
|
|
|
|
<include refid="selectGysJhVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-01-22 19:59:49 +08:00
|
|
|
<select id="getBySapNo" parameterType="String" resultMap="GysJhResult">
|
2025-05-30 16:13:27 +08:00
|
|
|
<include refid="selectGysJhVo"/>
|
|
|
|
|
WHERE sap_no = #{sapNo}
|
2025-05-27 14:38:00 +08:00
|
|
|
</select>
|
|
|
|
|
|
2025-07-25 17:04:11 +08:00
|
|
|
<select id="selectByIds" resultMap="GysJhResult">
|
2026-01-22 19:59:49 +08:00
|
|
|
SELECT *
|
|
|
|
|
FROM gys_jh
|
2025-07-25 17:04:11 +08:00
|
|
|
WHERE id IN
|
|
|
|
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
2025-07-24 14:19:42 +08:00
|
|
|
</select>
|
|
|
|
|
|
2025-05-27 14:38:00 +08:00
|
|
|
<insert id="insertGysJh" parameterType="GysJh" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into gys_jh
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="indexNo != null">index_no,</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="xj != null">xj,</if>
|
|
|
|
|
<if test="xmNo != null">xm_no,</if>
|
|
|
|
|
<if test="xmMs != null">xm_ms,</if>
|
|
|
|
|
<if test="wlNo != null">wl_no,</if>
|
|
|
|
|
<if test="wlMs != null">wl_ms,</if>
|
|
|
|
|
<if test="gysNo != null">gys_no,</if>
|
|
|
|
|
<if test="gysMc != null">gys_mc,</if>
|
|
|
|
|
<if test="jhAmt != null">jh_amt,</if>
|
|
|
|
|
<if test="htDj != null">ht_dj,</if>
|
|
|
|
|
<if test="sapNo != null">sap_no,</if>
|
|
|
|
|
<if test="xh != null">xh,</if>
|
|
|
|
|
<if test="jhQty != null">jh_qty,</if>
|
2026-01-22 19:59:49 +08:00
|
|
|
<!-- 新增 -->
|
|
|
|
|
<if test="realQty != null">real_qty,</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="htQty != null">ht_qty,</if>
|
|
|
|
|
<if test="dw != null">dw,</if>
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="status != null">status,</if>
|
2025-07-25 17:04:11 +08:00
|
|
|
<if test="entityId != null">entity_id,</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
<if test="isDelete != null">is_delete,</if>
|
2026-01-22 19:59:49 +08:00
|
|
|
</trim>
|
2025-05-27 14:38:00 +08:00
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="indexNo != null">#{indexNo},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="xj != null">#{xj},</if>
|
|
|
|
|
<if test="xmNo != null">#{xmNo},</if>
|
|
|
|
|
<if test="xmMs != null">#{xmMs},</if>
|
|
|
|
|
<if test="wlNo != null">#{wlNo},</if>
|
|
|
|
|
<if test="wlMs != null">#{wlMs},</if>
|
|
|
|
|
<if test="gysNo != null">#{gysNo},</if>
|
|
|
|
|
<if test="gysMc != null">#{gysMc},</if>
|
|
|
|
|
<if test="jhAmt != null">#{jhAmt},</if>
|
|
|
|
|
<if test="htDj != null">#{htDj},</if>
|
|
|
|
|
<if test="sapNo != null">#{sapNo},</if>
|
|
|
|
|
<if test="xh != null">#{xh},</if>
|
|
|
|
|
<if test="jhQty != null">#{jhQty},</if>
|
2026-01-22 19:59:49 +08:00
|
|
|
<!-- 新增 -->
|
|
|
|
|
<if test="realQty != null">#{realQty},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="htQty != null">#{htQty},</if>
|
|
|
|
|
<if test="dw != null">#{dw},</if>
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="status != null">#{status},</if>
|
2025-07-25 17:04:11 +08:00
|
|
|
<if test="entityId != null">#{entityId},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
<if test="isDelete != null">#{isDelete},</if>
|
2026-01-22 19:59:49 +08:00
|
|
|
</trim>
|
2025-05-27 14:38:00 +08:00
|
|
|
</insert>
|
|
|
|
|
|
2026-01-22 19:59:49 +08:00
|
|
|
<update id="increaseRealQtyById">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET real_qty = real_qty + #{realQty}
|
|
|
|
|
WHERE id = #{gysJhId}
|
|
|
|
|
</update>
|
2025-05-27 14:38:00 +08:00
|
|
|
<update id="updateGysJh" parameterType="GysJh">
|
|
|
|
|
update gys_jh
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="indexNo != null">index_no = #{indexNo},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="xj != null">xj = #{xj},</if>
|
|
|
|
|
<if test="xmNo != null">xm_no = #{xmNo},</if>
|
|
|
|
|
<if test="xmMs != null">xm_ms = #{xmMs},</if>
|
|
|
|
|
<if test="wlNo != null">wl_no = #{wlNo},</if>
|
|
|
|
|
<if test="wlMs != null">wl_ms = #{wlMs},</if>
|
|
|
|
|
<if test="gysNo != null">gys_no = #{gysNo},</if>
|
|
|
|
|
<if test="gysMc != null">gys_mc = #{gysMc},</if>
|
|
|
|
|
<if test="jhAmt != null">jh_amt = #{jhAmt},</if>
|
|
|
|
|
<if test="htDj != null">ht_dj = #{htDj},</if>
|
|
|
|
|
<if test="sapNo != null">sap_no = #{sapNo},</if>
|
|
|
|
|
<if test="xh != null">xh = #{xh},</if>
|
|
|
|
|
<if test="jhQty != null">jh_qty = #{jhQty},</if>
|
2026-01-22 19:59:49 +08:00
|
|
|
<!-- 新增 -->
|
|
|
|
|
<if test="realQty != null">real_qty = #{realQty},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="htQty != null">ht_qty = #{htQty},</if>
|
|
|
|
|
<if test="dw != null">dw = #{dw},</if>
|
2025-05-30 16:13:27 +08:00
|
|
|
<if test="status != null">status = #{status},</if>
|
2025-07-25 17:04:11 +08:00
|
|
|
<if test="entityId != null">entity_id = #{entityId},</if>
|
2025-05-27 14:38:00 +08:00
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
<if test="isDelete != null">is_delete = #{isDelete},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-01-22 19:59:49 +08:00
|
|
|
<!-- 下面原有方法全部保持不动 -->
|
2025-07-29 16:18:53 +08:00
|
|
|
<update id="updateStatusById" parameterType="map">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET status = #{status}
|
|
|
|
|
WHERE id = #{id}
|
2025-06-04 11:34:07 +08:00
|
|
|
</update>
|
|
|
|
|
|
2025-06-09 15:16:00 +08:00
|
|
|
<update id="resetGysJhStatusBySapNos">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET status = 0
|
|
|
|
|
WHERE sap_no IN
|
|
|
|
|
<foreach collection="sapNos" item="sapNo" open="(" separator="," close=")">
|
|
|
|
|
#{sapNo}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
2025-07-24 14:19:42 +08:00
|
|
|
|
|
|
|
|
<update id="batchUpdateStatusByIds">
|
|
|
|
|
UPDATE gys_jh
|
2025-07-25 17:04:11 +08:00
|
|
|
SET status = '2'
|
2025-07-24 14:19:42 +08:00
|
|
|
WHERE id IN
|
2025-07-25 17:04:11 +08:00
|
|
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
2025-07-24 14:19:42 +08:00
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
|
|
|
|
|
2025-07-25 17:04:11 +08:00
|
|
|
<update id="decreaseJhQtyById">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET jh_qty = jh_qty - #{realQty}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2025-05-27 14:38:00 +08:00
|
|
|
<delete id="deleteGysJhById" parameterType="Long">
|
|
|
|
|
delete from gys_jh where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteGysJhByIds" parameterType="String">
|
2026-01-22 19:59:49 +08:00
|
|
|
delete from gys_jh where id in
|
2025-05-27 14:38:00 +08:00
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
2025-12-05 16:04:35 +08:00
|
|
|
|
2026-01-19 10:16:14 +08:00
|
|
|
<select id="selectByWlNo" resultMap="GysJhResult">
|
|
|
|
|
SELECT *
|
|
|
|
|
FROM gys_jh
|
|
|
|
|
WHERE wl_no = #{wlNo}
|
|
|
|
|
AND is_delete = '0'
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-01-22 19:59:49 +08:00
|
|
|
<select id="selectMissingMtdItems"
|
|
|
|
|
resultType="com.zg.project.wisdom.domain.vo.PlanToMtdVO">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT
|
|
|
|
|
g.wl_no AS wlNo,
|
|
|
|
|
MAX(g.wl_ms) AS wlMs,
|
|
|
|
|
MAX(g.dw) AS dw,
|
|
|
|
|
MAX(g.ht_dj) AS htDj
|
|
|
|
|
FROM gys_jh g
|
|
|
|
|
LEFT JOIN mtd m ON m.mid = g.wl_no
|
|
|
|
|
WHERE g.wl_no IS NOT NULL
|
|
|
|
|
AND g.wl_no <> ''
|
|
|
|
|
AND m.mid IS NULL
|
|
|
|
|
GROUP BY g.wl_no
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
<!-- 查询当前已入库数量 -->
|
|
|
|
|
<select id="selectRealQtyById" resultType="java.math.BigDecimal">
|
|
|
|
|
SELECT real_qty
|
|
|
|
|
FROM gys_jh
|
|
|
|
|
WHERE id = #{jhId}
|
|
|
|
|
</select>
|
2026-01-19 10:16:14 +08:00
|
|
|
<update id="updateDwById">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET dw = #{dw}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
2025-12-05 16:04:35 +08:00
|
|
|
|
2026-01-22 19:59:49 +08:00
|
|
|
<update id="rollbackInQty">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET real_qty = real_qty - #{rollbackQty}
|
|
|
|
|
WHERE id = #{jhId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 回退状态 -->
|
|
|
|
|
<update id="updateStatus">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET status = #{status}
|
|
|
|
|
WHERE id = #{jhId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateRealQtyById">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET
|
|
|
|
|
real_qty = #{realQty},
|
|
|
|
|
update_time = NOW()
|
|
|
|
|
WHERE id = #{gysJhId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-01-26 17:01:42 +08:00
|
|
|
<update id="decreaseRealQtyById">
|
|
|
|
|
UPDATE gys_jh
|
|
|
|
|
SET real_qty = IFNULL(real_qty, 0) - #{rollbackQty}
|
|
|
|
|
WHERE id = #{gysJhId}
|
|
|
|
|
AND IFNULL(real_qty, 0) >= #{rollbackQty}
|
|
|
|
|
</update>
|
2026-04-03 09:32:41 +08:00
|
|
|
<update id="syncGysJhQty" parameterType="GysJh">
|
|
|
|
|
UPDATE gys_jh gj
|
|
|
|
|
JOIN rk_info ri
|
|
|
|
|
ON gj.sap_no = ri.sap_no
|
|
|
|
|
AND gj.wl_no = ri.wl_no
|
|
|
|
|
AND gj.xm_no = ri.xm_no
|
|
|
|
|
SET
|
|
|
|
|
gj.real_qty = ri.real_qty
|
|
|
|
|
WHERE (gj.is_delete = '0' OR gj.is_delete IS NULL)
|
|
|
|
|
AND (ri.is_delete = '0' OR ri.is_delete IS NULL)
|
|
|
|
|
AND ri.sap_no = #{sapNo}
|
|
|
|
|
AND ri.wl_no = #{wlNo}
|
|
|
|
|
AND ri.xm_no = #{xmNo}
|
|
|
|
|
</update>
|
2026-01-22 19:59:49 +08:00
|
|
|
</mapper>
|